Skip to content

Commit f8595cf

Browse files
committed
refactor: migrate management commands
Signed-off-by: Gabor Boros <[email protected]>
1 parent a779501 commit f8595cf

25 files changed

+3076
-112
lines changed

.coveragerc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ branch = True
44
omit = *tests*
55
*__init__*
66
rethinkdb/ql2_pb2.py
7+
rethinkdb/cli/main.py
8+
rethinkdb/cli/_export.py
9+
rethinkdb/cli/_index_rebuild.py
10+
rethinkdb/cli/_restore.py
11+
rethinkdb/cli/_dump.py
12+
rethinkdb/cli/_import.py
13+
rethinkdb/cli/_repl.py
14+
rethinkdb/cli/utils.py
715

816
[report]
917
sort = cover

.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
5+
exclude = .git,__pycache__,tests,rethinkdb/cli
66
per-file-ignores =
77
rethinkdb/cli/__init__.py: F401

CONTRIBUTING.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ As `step 0` make sure you have python 3.7+, [https://python-poetry.org/](poetry)
8787

8888
$ poetry env activate
8989
$ make protobuf
90+
$ make generate-init-pyi
9091
$ make format
9192
$ make lint
9293
$ make test

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ protobuf: ## download and convert protobuf file
110110
curl -sqo ${TARGET_PROTO_FILE} ${PROTO_FILE_URL}
111111
python ${FILE_CONVERTER_NAME} -l python -i ${TARGET_PROTO_FILE} -o ${TARGET_CONVERTED_PROTO_FILE}
112112

113+
.PHONY: generate-init-pyi
114+
generate-init-pyi: ## generate __init__.pyi file
115+
python scripts/generate_init_pyi.py
116+
isort rethinkdb/__init__.pyi
117+
black rethinkdb/__init__.pyi
118+
113119
.PHONY: test-unit
114120
test-unit: ## run unit tests and generate coverage
115121
coverage run -m pytest -m "not integration" -vv

README.rst

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -96,32 +96,34 @@ and install all development dependencies for you.
9696
Useful make Commands
9797
--------------------
9898

99-
+------------------+-------------------------------------+
100-
| Command | Description |
101-
+==================+=====================================+
102-
| help | Print available make commands |
103-
+------------------+-------------------------------------+
104-
| clean | Remove all artifacts |
105-
+------------------+-------------------------------------+
106-
| clean-build | Remove build artifacts |
107-
+------------------+-------------------------------------+
108-
| clean-mypy | Remove mypy artifacts |
109-
+------------------+-------------------------------------+
110-
| clean-pyc | Remove Python artifacts |
111-
+------------------+-------------------------------------+
112-
| clean-test | Remove test artifacts |
113-
+------------------+-------------------------------------+
114-
| docs | Generate Sphinx documentation |
115-
+------------------+-------------------------------------+
116-
| format | Run several formatters |
117-
+------------------+-------------------------------------+
118-
| lint | Run several linters after format |
119-
+------------------+-------------------------------------+
120-
| protobuf | Download and convert protobuf file |
121-
+------------------+-------------------------------------+
122-
| test | Run all tests with coverage |
123-
+------------------+-------------------------------------+
124-
| test-unit | Run unit tests with coverage |
125-
+------------------+-------------------------------------+
126-
| test-integration | Run integration tests with coverage |
127-
+------------------+-------------------------------------+
99+
+---------------------+---------------------------------------------------------------+
100+
| Command | Description |
101+
+=====================+===============================================================+
102+
| help | show help message and exit |
103+
+---------------------+---------------------------------------------------------------+
104+
| clean | remove all build, test, coverage and Python artifacts |
105+
+---------------------+---------------------------------------------------------------+
106+
| clean-build | remove build artifacts |
107+
+---------------------+---------------------------------------------------------------+
108+
| clean-mypy | remove mypy related artifacts |
109+
+---------------------+---------------------------------------------------------------+
110+
| clean-pyc | remove Python file artifacts |
111+
+---------------------+---------------------------------------------------------------+
112+
| clean-test | remove test and coverage artifacts |
113+
+---------------------+---------------------------------------------------------------+
114+
| docs | generate Sphinx HTML documentation, including API docs |
115+
+---------------------+---------------------------------------------------------------+
116+
| format | run formatters on the package |
117+
+---------------------+---------------------------------------------------------------+
118+
| generate-init-pyi | generate __init__.pyi file |
119+
+---------------------+---------------------------------------------------------------+
120+
| lint | run linters against the package |
121+
+---------------------+---------------------------------------------------------------+
122+
| protobuf | download and convert protobuf file |
123+
+---------------------+---------------------------------------------------------------+
124+
| test | run all tests and generate coverage |
125+
+---------------------+---------------------------------------------------------------+
126+
| test-integration | run unit tests and generate coverage |
127+
+---------------------+---------------------------------------------------------------+
128+
| test-unit | run unit tests and generate coverage |
129+
+---------------------+---------------------------------------------------------------+

docs/rethinkdb.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ rethinkdb.repl module
6868
:undoc-members:
6969
:show-inheritance:
7070

71-
rethinkdb.utilities module
72-
--------------------------
71+
rethinkdb.utils module
72+
----------------------
7373

74-
.. automodule:: rethinkdb.utilities
74+
.. automodule:: rethinkdb.utils
7575
:members:
7676
:undoc-members:
7777
:show-inheritance:

mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
[mypy]
2+
exclude = rethinkdb/cli/.*

pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ extension-pkg-whitelist=
77

88
# Add files or directories to the blacklist. They should be base names, not
99
# paths.
10-
ignore=CVS
10+
ignore=CVS,
11+
rethinkdb/cli
1112

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

rethinkdb/__init__.pyi

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
from collections.abc import Callable, Iterable, Mapping
2+
from datetime import date, datetime
3+
from typing import Any, Optional, Type, Union
4+
5+
from rethinkdb.ast import ImplicitVar, ReqlBinary, ReqlQuery, ReqlTzinfo
6+
from rethinkdb.errors import (
7+
InvalidHandshakeStateError,
8+
QueryPrinter,
9+
ReqlAuthError,
10+
ReqlCompileError,
11+
ReqlCursorEmpty,
12+
ReqlDriverCompileError,
13+
ReqlDriverError,
14+
ReqlError,
15+
ReqlInternalError,
16+
ReqlNonExistenceError,
17+
ReqlOpFailedError,
18+
ReqlOpIndeterminateError,
19+
ReqlOperationError,
20+
ReqlPermissionError,
21+
ReqlQueryLogicError,
22+
ReqlResourceLimitError,
23+
ReqlRuntimeError,
24+
ReqlServerCompileError,
25+
ReqlTimeoutError,
26+
ReqlUserError,
27+
)
28+
from rethinkdb.net import Connection, Cursor, DefaultConnection
29+
from rethinkdb.query import ReqlConstant
30+
31+
class RethinkDB:
32+
Connection: Type[Connection]
33+
Cursor: Type[Cursor]
34+
DEFAULT_PORT: int
35+
DefaultConnection: Type[DefaultConnection]
36+
def make_connection(
37+
connection_type: Any,
38+
kwargs: Any,
39+
host: Any = ...,
40+
port: Any = ...,
41+
db: Any = ...,
42+
user: Any = ...,
43+
password: Any = ...,
44+
timeout: Any = ...,
45+
ssl: Any = ...,
46+
url: Any = ...,
47+
handshake_version: Any = ...,
48+
) -> Any: ...
49+
def add(arguments: Any) -> Any: ...
50+
def and_(arguments: Any) -> Any: ...
51+
april: ReqlConstant
52+
def args(arguments: Any) -> Any: ...
53+
def asc(arguments: Any) -> Any: ...
54+
august: ReqlConstant
55+
def avg(arguments: Any) -> Any: ...
56+
def binary(data: Any) -> Any: ...
57+
def bit_and(arguments: Any) -> Any: ...
58+
def bit_not(arguments: Any) -> Any: ...
59+
def bit_or(arguments: Any) -> Any: ...
60+
def bit_sal(arguments: Any) -> Any: ...
61+
def bit_sar(arguments: Any) -> Any: ...
62+
def bit_xor(arguments: Any) -> Any: ...
63+
def branch(arguments: Any) -> Any: ...
64+
def ceil(arguments: Any) -> Any: ...
65+
def circle(arguments: Any, kwargs: Any) -> Any: ...
66+
def contains(arguments: Any) -> Any: ...
67+
def count(arguments: Any) -> Any: ...
68+
def db(arguments: Any) -> Any: ...
69+
def db_create(arguments: Any) -> Any: ...
70+
def db_drop(arguments: Any) -> Any: ...
71+
def db_list(arguments: Any) -> Any: ...
72+
december: ReqlConstant
73+
def desc(arguments: Any) -> Any: ...
74+
def distance(arguments: Any, kwargs: Any) -> Any: ...
75+
def distinct(arguments: Any) -> Any: ...
76+
def div(arguments: Any) -> Any: ...
77+
def do(arguments: Any) -> Any: ...
78+
def epoch_time(arguments: Any) -> Any: ...
79+
def eq(arguments: Any) -> Any: ...
80+
def error(msg: Any) -> Any: ...
81+
february: ReqlConstant
82+
def floor(arguments: Any) -> Any: ...
83+
def format(arguments: Any, kwargs: Any) -> Any: ...
84+
friday: ReqlConstant
85+
def ge(arguments: Any) -> Any: ...
86+
def geojson(arguments: Any) -> Any: ...
87+
def grant(arguments: Any, kwargs: Any) -> Any: ...
88+
def group(arguments: Any) -> Any: ...
89+
def gt(arguments: Any) -> Any: ...
90+
def http(url: Any, kwargs: Any) -> Any: ...
91+
def info(arguments: Any) -> Any: ...
92+
def intersects(arguments: Any) -> Any: ...
93+
def iso8601(arguments: Any, kwargs: Any) -> Any: ...
94+
january: ReqlConstant
95+
def json(arguments: Any) -> Any: ...
96+
july: ReqlConstant
97+
june: ReqlConstant
98+
def le(arguments: Any) -> Any: ...
99+
def line(arguments: Any) -> Any: ...
100+
def literal(arguments: Any) -> Any: ...
101+
def lt(arguments: Any) -> Any: ...
102+
def make_timezone(arguments: Any) -> Any: ...
103+
def map(arguments: Any) -> Any: ...
104+
march: ReqlConstant
105+
def max(arguments: Any) -> Any: ...
106+
maxval: ReqlConstant
107+
may: ReqlConstant
108+
def min(arguments: Any) -> Any: ...
109+
minval: ReqlConstant
110+
def mod(arguments: Any) -> Any: ...
111+
monday: ReqlConstant
112+
def mul(arguments: Any) -> Any: ...
113+
def ne(arguments: Any) -> Any: ...
114+
def not_(arguments: Any) -> Any: ...
115+
november: ReqlConstant
116+
def now(arguments: Any) -> Any: ...
117+
def object(arguments: Any) -> Any: ...
118+
october: ReqlConstant
119+
def or_(arguments: Any) -> Any: ...
120+
def point(arguments: Any) -> Any: ...
121+
def polygon(arguments: Any) -> Any: ...
122+
def random(arguments: Any, kwargs: Any) -> Any: ...
123+
def range(arguments: Any) -> Any: ...
124+
def reduce(arguments: Any) -> Any: ...
125+
def round(arguments: Any) -> Any: ...
126+
row: ImplicitVar
127+
saturday: ReqlConstant
128+
september: ReqlConstant
129+
def sub(arguments: Any) -> Any: ...
130+
def sum(arguments: Any) -> Any: ...
131+
sunday: ReqlConstant
132+
def table(arguments: Any, kwargs: Any) -> Any: ...
133+
def table_create(arguments: Any, kwargs: Any) -> Any: ...
134+
def table_drop(arguments: Any) -> Any: ...
135+
def table_list(arguments: Any) -> Any: ...
136+
thursday: ReqlConstant
137+
def time(arguments: Any) -> Any: ...
138+
tuesday: ReqlConstant
139+
def type_of(arguments: Any) -> Any: ...
140+
def union(arguments: Any) -> Any: ...
141+
def uuid(arguments: Any) -> Any: ...
142+
wednesday: ReqlConstant
143+
def js(arguments: Any, kwargs: Any) -> Any: ...
144+
def expr(
145+
self,
146+
val: Union[
147+
str,
148+
bytes,
149+
ReqlQuery,
150+
ReqlBinary,
151+
date,
152+
datetime,
153+
Mapping,
154+
Iterable,
155+
Callable,
156+
],
157+
nesting_depth: int = ...,
158+
) -> Any: ...
159+
ReqlQuery: Type[ReqlQuery]
160+
ReqlBinary: Type[ReqlBinary]
161+
ReqlTzinfo: Type[ReqlTzinfo]
162+
InvalidHandshakeStateError: Type[InvalidHandshakeStateError]
163+
QueryPrinter: Type[QueryPrinter]
164+
ReqlAuthError: Type[ReqlAuthError]
165+
ReqlCompileError: Type[ReqlCompileError]
166+
ReqlCursorEmpty: Type[ReqlCursorEmpty]
167+
ReqlDriverCompileError: Type[ReqlDriverCompileError]
168+
ReqlDriverError: Type[ReqlDriverError]
169+
ReqlError: Type[ReqlError]
170+
ReqlInternalError: Type[ReqlInternalError]
171+
ReqlNonExistenceError: Type[ReqlNonExistenceError]
172+
ReqlOpFailedError: Type[ReqlOpFailedError]
173+
ReqlOpIndeterminateError: Type[ReqlOpIndeterminateError]
174+
ReqlOperationError: Type[ReqlOperationError]
175+
ReqlPermissionError: Type[ReqlPermissionError]
176+
ReqlQueryLogicError: Type[ReqlQueryLogicError]
177+
ReqlResourceLimitError: Type[ReqlResourceLimitError]
178+
ReqlRuntimeError: Type[ReqlRuntimeError]
179+
ReqlServerCompileError: Type[ReqlServerCompileError]
180+
ReqlTimeoutError: Type[ReqlTimeoutError]
181+
ReqlUserError: Type[ReqlUserError]
182+
# Methods
183+
def set_loop_type(self, library: Optional[str] = None) -> None: ...
184+
185+
r: RethinkDB

rethinkdb/ast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from rethinkdb import ql2_pb2
4141
from rethinkdb.errors import QueryPrinter, ReqlDriverCompileError, ReqlDriverError
4242
from rethinkdb.repl import Repl
43-
from rethinkdb.utilities import EnhancedTuple
43+
from rethinkdb.utils import EnhancedTuple
4444

4545
if TYPE_CHECKING:
4646
from rethinkdb.net import Connection

0 commit comments

Comments
 (0)