Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit419e9a8

Browse files
committed
refactor: fix typing issues and cleanup code
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
1 parentc6a28be commit419e9a8

19 files changed

+109
-416
lines changed

‎.flake8‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
ignore=E203,E501,W503
33
max-line-length=88
44
application_import_names=rethinkdb
5-
exclude = .git,__pycache__,tests,scripts,rethinkdb/cli
5+
exclude = .git,__pycache__,tests,scripts,rethinkdb/cli,rethinkdb/ql2_pb2.py
66
per-file-ignores =
77
rethinkdb/cli/__init__.py: F401

‎.pre-commit-config.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ repos:
99
rev:v6.0.0
1010
hooks:
1111
-id:trailing-whitespace
12+
exclude:^rethinkdb/ql2_pb2\.py$
1213
-id:end-of-file-fixer
14+
exclude:^rethinkdb/ql2_pb2\.py$
1315
-id:check-toml
1416
-id:check-json
1517
-id:pretty-format-json

‎mypy.ini‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[mypy]
2-
exclude = rethinkdb/cli/.*,scripts/.*
2+
exclude = rethinkdb/cli/.*,scripts/.*,.*ql2_pb2\.py

‎pylintrc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ extension-pkg-whitelist=
99
# paths.
1010
ignore=CVS,
1111
rethinkdb/cli,
12-
scripts
12+
scripts,
13+
rethinkdb/ql2_pb2.py
1314

1415
# Add files or directories matching the regex patterns to the blacklist. The
1516
# regex matches against base names, not paths.

‎pyproject.toml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ maintainers = ["RethinkDB <bugs@rethinkdb.com>"]
3838
# RethinkDB is aliasing the commands to `rethinkdb <command>`, therefore it
3939
# can be executed as `rethinkdb dump` or `rethinkdb-dump`.
4040
[tool.poetry.scripts]
41-
rethinkdb ="rethinkdb.cli.main:cmd_main"
4241
rethinkdb-dump ="rethinkdb.cli._dump:cmd_dump"
4342
rethinkdb-export ="rethinkdb.cli._export:cmd_export"
4443
rethinkdb-import ="rethinkdb.cli._import:cmd_import"
@@ -69,6 +68,21 @@ all = []
6968

7069
[tool.black]
7170
target-version = ['py312']
71+
exclude ='''
72+
/(
73+
\.eggs
74+
| \.git
75+
| \.hg
76+
| \.mypy_cache
77+
| \.tox
78+
| \.venv
79+
| _build
80+
| buck-out
81+
| build
82+
| dist
83+
| rethinkdb/ql2_pb2\.py
84+
)/
85+
'''
7286

7387
[tool.isort]
7488
atomic =true

‎rethinkdb/__init__.py‎

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,62 @@
1616
# Copyright 2010-2016 RethinkDB, all rights reserved.
1717

1818
importwarnings
19+
fromtypesimportSimpleNamespace
20+
21+
fromrethinkdbimportnet
22+
# pylint: disable=redefined-builtin
23+
fromrethinkdb.queryimport (
24+
add,and_,april,args,asc,august,avg,binary,bit_and,bit_not,bit_or,
25+
bit_sal,bit_sar,bit_xor,branch,ceil,circle,contains,count,db,
26+
db_create,db_drop,db_list,december,desc,distance,distinct,div,do,
27+
epoch_time,eq,error,february,floor,format,friday,ge,geojson,grant,
28+
group,gt,http,info,intersects,iso8601,january,json,july,june,le,
29+
line,literal,lt,make_timezone,map,march,max,maxval,may,min,minval,
30+
mod,monday,mul,ne,not_,november,now,object,october,or_,point,
31+
polygon,random,range,reduce,round,row,saturday,september,sub,sum,
32+
sunday,table,table_create,table_drop,table_list,thursday,time,tuesday,
33+
type_of,union,uuid,wednesday,js
34+
)
35+
# pylint: enable=redefined-builtin
1936

20-
fromrethinkdbimporterrors# , version
21-
22-
__all__= ["r","RethinkDB"]
2337
__version__="2.5.0"
2438

25-
26-
classRethinkDB:
39+
# Create the r namespace object containing all query functions
40+
r=SimpleNamespace()
41+
42+
query_functions= {
43+
'add':add,'and_':and_,'april':april,'args':args,'asc':asc,
44+
'august':august,'avg':avg,'binary':binary,'bit_and':bit_and,
45+
'bit_not':bit_not,'bit_or':bit_or,'bit_sal':bit_sal,'bit_sar':bit_sar,
46+
'bit_xor':bit_xor,'branch':branch,'ceil':ceil,'circle':circle,
47+
'contains':contains,'count':count,'db':db,'db_create':db_create,
48+
'db_drop':db_drop,'db_list':db_list,'december':december,'desc':desc,
49+
'distance':distance,'distinct':distinct,'div':div,'do':do,
50+
'epoch_time':epoch_time,'eq':eq,'error':error,'february':february,
51+
'floor':floor,'format':format,'friday':friday,'ge':ge,'geojson':geojson,
52+
'grant':grant,'group':group,'gt':gt,'http':http,'info':info,
53+
'intersects':intersects,'iso8601':iso8601,'january':january,'json':json,
54+
'july':july,'june':june,'le':le,'line':line,'literal':literal,
55+
'lt':lt,'make_timezone':make_timezone,'map':map,'march':march,
56+
'max':max,'maxval':maxval,'may':may,'min':min,'minval':minval,
57+
'mod':mod,'monday':monday,'mul':mul,'ne':ne,'not_':not_,
58+
'november':november,'now':now,'object':object,'october':october,
59+
'or_':or_,'point':point,'polygon':polygon,'random':random,
60+
'range':range,'reduce':reduce,'round':round,'row':row,
61+
'saturday':saturday,'september':september,'sub':sub,'sum':sum,
62+
'sunday':sunday,'table':table,'table_create':table_create,
63+
'table_drop':table_drop,'table_list':table_list,'thursday':thursday,
64+
'time':time,'tuesday':tuesday,'type_of':type_of,'union':union,
65+
'uuid':uuid,'wednesday':wednesday,'js':js
66+
}
67+
68+
forname,funcinquery_functions.items():
69+
setattr(r,name,func)
70+
71+
72+
classClient:
2773
"""
28-
RethinkDB serves as an entrypoint for queries.
74+
Client is a wrapper around RethinkDB connection handling.
2975
3076
It constructs the connection handlers and event loops, re-exports internal modules for easier
3177
use, and sets the event loop.
@@ -34,23 +80,11 @@ class RethinkDB:
3480
def__init__(self):
3581
super().__init__()
3682

37-
# pylint: disable=import-outside-toplevel
38-
fromrethinkdbimportast,net,query
39-
40-
# Re-export internal modules for backward compatibility
41-
self.ast=ast
42-
self.errors=errors
4383
self.net=net
44-
self.query=query
4584

4685
net.Connection._r=self
4786
self.connection_type=None
4887

49-
# Dynamically assign every re-exported internal module's function to self
50-
formodulein (self.net,self.query,self.ast,self.errors):
51-
forfunction_nameinmodule.__all__:
52-
setattr(self,function_name,getattr(module,function_name))
53-
5488
# Ensure the `make_connection` function is not overridden accidentally
5589
self.make_connection=self.net.make_connection
5690
self.set_loop_type(None)
@@ -83,12 +117,9 @@ def set_loop_type(self, library=None) -> None:
83117
iflibraryisNoneorself.connection_typeisNone:
84118
self.connection_type=self.net.DefaultConnection
85119

86-
defconnect(self,*args,**kwargs):
120+
defconnect(self,*connect_args,**kwargs):
87121
"""
88122
Make a connection to the database.
89123
"""
90124

91-
returnself.make_connection(self.connection_type,*args,**kwargs)
92-
93-
94-
r=RethinkDB()
125+
returnself.make_connection(self.connection_type,*connect_args,**kwargs)

‎rethinkdb/__init__.pyi‎

Lines changed: 0 additions & 185 deletions
This file was deleted.

‎rethinkdb/cli/_dump.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333

3434
importclick
3535

36-
fromrethinkdbimporterrors,r
36+
importrethinkdbasr
37+
fromrethinkdbimporterrors
3738
fromrethinkdb.cli.utilsimport (
3839
common_options,
3940
get_connection,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp