Skip to content

Commit 7e8c024

Browse files
committed
fixed mypy and ruff lint errors
1 parent 4518c65 commit 7e8c024

File tree

7 files changed

+39
-26
lines changed

7 files changed

+39
-26
lines changed

ellar_sql/cli/commands.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ def db():
3636
@click.option(
3737
"--sql",
3838
is_flag=True,
39-
help="Don't emit SQL to database - dump to standard output " "instead",
39+
help="Don't emit SQL to database - dump to standard output instead",
4040
)
4141
@click.option(
4242
"--head",
4343
default="head",
44-
help="Specify head revision or <branchname>@head to base new " "revision on",
44+
help="Specify head revision or <branchname>@head to base new revision on",
4545
)
4646
@click.option(
4747
"--splice",
@@ -61,7 +61,7 @@ def db():
6161
@click.option(
6262
"--rev-id",
6363
default=None,
64-
help="Specify a hardcoded revision id instead of generating " "one",
64+
help="Specify a hardcoded revision id instead of generating one",
6565
)
6666
@click.pass_context
6767
def revision(
@@ -102,12 +102,12 @@ def revision(
102102
@click.option(
103103
"--sql",
104104
is_flag=True,
105-
help="Don't emit SQL to database - dump to standard output " "instead",
105+
help="Don't emit SQL to database - dump to standard output instead",
106106
)
107107
@click.option(
108108
"--head",
109109
default="head",
110-
help="Specify head revision or <branchname>@head to base new " "revision on",
110+
help="Specify head revision or <branchname>@head to base new revision on",
111111
)
112112
@click.option(
113113
"--splice",
@@ -127,7 +127,7 @@ def revision(
127127
@click.option(
128128
"--rev-id",
129129
default=None,
130-
help="Specify a hardcoded revision id instead of generating " "one",
130+
help="Specify a hardcoded revision id instead of generating one",
131131
)
132132
@click.option(
133133
"-x",
@@ -195,7 +195,7 @@ def edit(ctx, directory, revision):
195195
@click.option(
196196
"--rev-id",
197197
default=None,
198-
help="Specify a hardcoded revision id instead of generating " "one",
198+
help="Specify a hardcoded revision id instead of generating one",
199199
)
200200
@click.argument("revisions", nargs=-1)
201201
@click.pass_context
@@ -215,12 +215,12 @@ def merge(ctx, directory, message, branch_label, rev_id, revisions):
215215
@click.option(
216216
"--sql",
217217
is_flag=True,
218-
help="Don't emit SQL to database - dump to standard output " "instead",
218+
help="Don't emit SQL to database - dump to standard output instead",
219219
)
220220
@click.option(
221221
"--tag",
222222
default=None,
223-
help='Arbitrary "tag" name - can be used by custom env.py ' "scripts",
223+
help='Arbitrary "tag" name - can be used by custom env.py scripts',
224224
)
225225
@click.option(
226226
"-x",
@@ -246,12 +246,12 @@ def upgrade(ctx, directory, sql, tag, x_arg, revision):
246246
@click.option(
247247
"--sql",
248248
is_flag=True,
249-
help="Don't emit SQL to database - dump to standard output " "instead",
249+
help="Don't emit SQL to database - dump to standard output instead",
250250
)
251251
@click.option(
252252
"--tag",
253253
default=None,
254-
help='Arbitrary "tag" name - can be used by custom env.py ' "scripts",
254+
help='Arbitrary "tag" name - can be used by custom env.py scripts',
255255
)
256256
@click.option(
257257
"-x",
@@ -300,7 +300,7 @@ def show(ctx: click.Context, directory, revision):
300300
"-i",
301301
"--indicate-current",
302302
is_flag=True,
303-
help="Indicate current version (Alembic 0.9.9 or greater is " "required)",
303+
help="Indicate current version (Alembic 0.9.9 or greater is required)",
304304
)
305305
@click.pass_context
306306
def history(ctx: click.Context, directory, rev_range, verbose, indicate_current):
@@ -369,12 +369,12 @@ def current(ctx: click.Context, directory, verbose):
369369
@click.option(
370370
"--sql",
371371
is_flag=True,
372-
help="Don't emit SQL to database - dump to standard output " "instead",
372+
help="Don't emit SQL to database - dump to standard output instead",
373373
)
374374
@click.option(
375375
"--tag",
376376
default=None,
377-
help='Arbitrary "tag" name - can be used by custom env.py ' "scripts",
377+
help='Arbitrary "tag" name - can be used by custom env.py scripts',
378378
)
379379
@click.argument("revision", default="head")
380380
@click.pass_context
@@ -416,7 +416,7 @@ def check(ctx: click.Context, directory):
416416
@click.option(
417417
"--package",
418418
is_flag=True,
419-
help="Write empty __init__.py files to the environment and " "version locations",
419+
help="Write empty __init__.py files to the environment and version locations",
420420
)
421421
@click.pass_context
422422
def init(ctx: click.Context, directory, multiple, package):

ellar_sql/model/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ def __new__(
6262
)
6363
if isinstance(options, dict):
6464
options = ModelBaseConfig(**options)
65-
assert isinstance(
66-
options, ModelBaseConfig
67-
), f"{options.__class__} is not a support ModelMetaOptions"
65+
assert isinstance(options, ModelBaseConfig), (
66+
f"{options.__class__} is not a support ModelMetaOptions"
67+
)
6868

6969
if options.as_base:
7070
declarative_bases = _get_declarative_bases(options.use_bases)

ellar_sql/model/typeDecorator/file/file.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ class File(BaseFile, AttributeDictAccessMixin):
4848

4949
files: t.List[str]
5050

51+
# Type hints for dict-like methods from parent classes
52+
if t.TYPE_CHECKING:
53+
54+
def get(self, __key: str, __default: t.Any = None) -> t.Any: ...
55+
56+
def __setitem__(self, __key: str, __value: t.Any) -> None: ...
57+
58+
def __getitem__(self, __key: str) -> t.Any: ...
59+
5160
def __init__(
5261
self,
5362
content: t.Any = None,

ellar_sql/pagination/decorator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ def _prepare_template_response(
7474
]:
7575
if isinstance(res, tuple):
7676
filter_query, extra_context = res
77-
assert isinstance(
78-
extra_context, dict
79-
), "When using as `template_context`, route function should return a tuple(select, {})"
77+
assert isinstance(extra_context, dict), (
78+
"When using as `template_context`, route function should return a tuple(select, {})"
79+
)
8080

8181
elif isinstance(res, dict):
8282
filter_query = None

ellar_sql/services/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def engines(self) -> t.Dict[str, sa.Engine]:
7373

7474
@property
7575
def engine(self) -> sa.Engine:
76-
assert self._engines[self].get(
77-
DEFAULT_KEY
78-
), f"{self.__class__.__name__} configuration is not ready"
76+
assert self._engines[self].get(DEFAULT_KEY), (
77+
f"{self.__class__.__name__} configuration is not ready"
78+
)
7979
return self._engines[self][DEFAULT_KEY]
8080

8181
def _setup(

samples/db-learning/db_learning/command.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ def seed_user():
1212
session = db_service.session_factory()
1313

1414
for i in range(300):
15-
session.add(User(username=f"username-{i+1}", email=f"user{i+1}[email protected]"))
15+
session.add(
16+
User(username=f"username-{i + 1}", email=f"user{i + 1}[email protected]")
17+
)
1618

1719
session.commit()
1820
db_service.session_factory.remove()

samples/index-script/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def main():
2020
session = db_service.session_factory()
2121

2222
for i in range(50):
23-
session.add(User(username=f"username-{i+1}", email=f"user{i+1}[email protected]"))
23+
session.add(
24+
User(username=f"username-{i + 1}", email=f"user{i + 1}[email protected]")
25+
)
2426

2527
session.commit()
2628
rows = session.execute(model.select(User)).scalars()

0 commit comments

Comments
 (0)