Skip to content

Commit 247ad1b

Browse files
committed
Check entire project with mypy
1 parent 712e753 commit 247ad1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+136
-120
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
make venv-install
5656
5757
- name: Run mypy
58-
run: uv run mypy --config-file ./pyproject.toml ./syncmaster/server
58+
run: uv run mypy syncmaster
5959

6060
codeql:
6161
name: CodeQL

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ repos:
8585
hooks:
8686
- id: pretty-format-yaml
8787
args: [--autofix, --indent, '2', --offset, '2']
88-
priority: 8
88+
priority: 7
8989

9090
- repo: https://github.com/codespell-project/codespell
9191
rev: v2.4.1
@@ -95,32 +95,32 @@ repos:
9595
additional_dependencies:
9696
- tomli
9797
exclude: .*\.svg
98-
priority: 9
98+
priority: 8
9999

100100
- repo: https://github.com/astral-sh/uv-pre-commit
101101
rev: 0.9.18
102102
hooks:
103103
- id: uv-lock
104-
priority: 10
104+
priority: 9
105105

106106
- repo: https://github.com/astral-sh/ruff-pre-commit
107107
rev: v0.14.10
108108
hooks:
109109
- id: ruff-format
110-
priority: 10
110+
priority: 9
111111
- id: ruff-check
112112
args: [--fix]
113-
priority: 11
113+
priority: 10
114114

115115
- repo: local
116116
hooks:
117117
- id: mypy
118118
name: mypy
119-
entry: mypy ./syncmaster/server --config-file ./pyproject.toml
119+
entry: mypy syncmaster
120120
language: python
121121
require_serial: true
122122
pass_filenames: false
123-
priority: 11
123+
priority: 10
124124

125125
- repo: meta
126126
hooks:

pyproject.toml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,6 @@ ignore_missing_imports = true
201201
module = "celery.*"
202202
ignore_missing_imports = true
203203

204-
[[tool.mypy.overrides]]
205-
module = "fastapi.*"
206-
ignore_missing_imports = true
207-
208204
[[tool.mypy.overrides]]
209205
module = "kombu.*"
210206
ignore_missing_imports = true
@@ -213,20 +209,16 @@ ignore_missing_imports = true
213209
module = "onetl.*"
214210
ignore_missing_imports = true
215211

216-
[[tool.mypy.overrides]]
217-
module = "pyspark.*"
218-
ignore_missing_imports = true
219-
220212
[[tool.mypy.overrides]]
221213
module = "sqlalchemy_utils.*"
222214
ignore_missing_imports = true
223215

224216
[[tool.mypy.overrides]]
225-
module = "starlette.*"
217+
module = "apscheduler.*"
226218
ignore_missing_imports = true
227219

228220
[[tool.mypy.overrides]]
229-
module = "uvicorn.*"
221+
module = "pydantic_settings_logging"
230222
ignore_missing_imports = true
231223

232224
[tool.pytest.ini_options]

syncmaster/db/migrations/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
class MigrationAppSettings(BaseSettings):
27-
database: DatabaseSettings = Field(default_factory=DatabaseSettings, description="Database settings")
27+
database: DatabaseSettings = Field(default_factory=DatabaseSettings, description="Database settings") # type: ignore[arg-type]
2828
logging: LoggingSettings = Field(default=DEFAULT_LOGGING_SETTINGS, description="Logging settings")
2929

3030

syncmaster/db/models/auth_data.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111

1212
class AuthData(Base, TimestampMixin):
13+
__table_name__ = "auth_data"
14+
1315
connection_id: Mapped[int] = mapped_column(
1416
BigInteger,
1517
ForeignKey("connection.id", ondelete="CASCADE"),

syncmaster/db/models/base.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
# SPDX-FileCopyrightText: 2023-present MTS PJSC
22
# SPDX-License-Identifier: Apache-2.0
3-
import re
4-
53
from sqlalchemy import MetaData
6-
from sqlalchemy.orm import DeclarativeBase, declared_attr
4+
from sqlalchemy.orm import DeclarativeBase
75

86
convention = {
9-
"all_column_names": lambda constraint, table: "_".join([column.name for column in constraint.columns.values()]),
107
"ix": "ix__%(table_name)s__%(all_column_names)s",
118
"uq": "uq__%(table_name)s__%(all_column_names)s",
129
"ck": "ck__%(table_name)s__%(constraint_name)s",
1310
"fk": ("fk__%(table_name)s__%(all_column_names)s__%(referred_table_name)s"),
1411
"pk": "pk__%(table_name)s",
1512
}
1613

17-
model_metadata = MetaData(naming_convention=convention)
18-
1914

2015
# as_declarative decorator causes mypy errors.
2116
# Use inheritance from DeclarativeBase.
2217
class Base(DeclarativeBase):
23-
metadata = model_metadata
24-
25-
@declared_attr
26-
def __tablename__(cls) -> str: # noqa: N805
27-
name_list = re.findall(r"[A-Z][a-z\d]*", cls.__name__)
28-
return "_".join(name_list).lower()
18+
metadata = MetaData(naming_convention=convention)

syncmaster/db/models/connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class ConnectionType(StrEnum):
3333

3434

3535
class Connection(Base, ResourceMixin, TimestampMixin):
36+
__table_name__ = "connection"
3637
__table_args__ = (
3738
UniqueConstraint("name", "group_id"),
3839
Index("idx_connection_search_vector", "search_vector", postgresql_using="gin"),

syncmaster/db/models/group.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def roles_at_least(cls, role: str | GroupMemberRole) -> list[str]:
6666

6767

6868
class Group(Base, TimestampMixin):
69+
__table_name__ = "group"
70+
6971
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
7072
name: Mapped[str] = mapped_column(String(128), nullable=False, unique=True)
7173
description: Mapped[str] = mapped_column(String(512), nullable=False, default="")
@@ -99,7 +101,9 @@ def __repr__(self) -> str:
99101

100102

101103
class UserGroup(Base):
104+
__table_name__ = "user_group"
102105
__table_args__ = (PrimaryKeyConstraint("user_id", "group_id"),)
106+
103107
user_id: Mapped[int] = mapped_column(
104108
BigInteger,
105109
ForeignKey("user.id", ondelete="CASCADE"),

syncmaster/db/models/queue.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313

1414
class Queue(Base, ResourceMixin, TimestampMixin):
15+
__table_name__ = "queue"
16+
1517
name: Mapped[str] = mapped_column(String(128), nullable=False)
1618
slug: Mapped[str] = mapped_column(String(256), nullable=False, unique=True)
1719

syncmaster/db/models/run.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class RunType(enum.StrEnum):
3030

3131

3232
class Run(Base, TimestampMixin):
33+
__table_name__ = "run"
34+
3335
id: Mapped[int] = mapped_column(
3436
BigInteger,
3537
primary_key=True,

0 commit comments

Comments
 (0)