From 8d07010e39f5fb580d33c75332804b2c7e7da24e Mon Sep 17 00:00:00 2001 From: Artur Shiriev Date: Mon, 9 Mar 2026 10:17:30 +0300 Subject: [PATCH] migrate to ty --- Justfile | 4 ++-- modern_di/providers/container_provider.py | 2 +- modern_di/providers/context_provider.py | 2 +- modern_di/providers/factory.py | 4 +++- pyproject.toml | 6 +----- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Justfile b/Justfile index fabf8c0..0853917 100644 --- a/Justfile +++ b/Justfile @@ -8,13 +8,13 @@ lint: uv run eof-fixer . uv run ruff format uv run ruff check --fix - uv run mypy . + uv run ty check lint-ci: uv run eof-fixer . --check uv run ruff format --check uv run ruff check --no-fix - uv run mypy . + uv run ty check test *args: uv run --no-sync pytest {{ args }} diff --git a/modern_di/providers/container_provider.py b/modern_di/providers/container_provider.py index 0887948..a500441 100644 --- a/modern_di/providers/container_provider.py +++ b/modern_di/providers/container_provider.py @@ -17,7 +17,7 @@ def __init__(self) -> None: def resolve(self, container: "Container") -> "Container": return container - def validate(self, _: "Container") -> dict[str, typing.Any]: + def validate(self, container: "Container") -> dict[str, typing.Any]: # noqa: ARG002 return {"self": self} diff --git a/modern_di/providers/context_provider.py b/modern_di/providers/context_provider.py index fe0f0d9..71a7af4 100644 --- a/modern_di/providers/context_provider.py +++ b/modern_di/providers/context_provider.py @@ -15,7 +15,7 @@ class ContextProvider(AbstractProvider[types.T_co]): def __init__(self, *, scope: Scope = Scope.APP, context_type: type[types.T_co]) -> None: super().__init__(scope=scope, bound_type=context_type) - def validate(self, _: "Container") -> dict[str, typing.Any]: + def validate(self, container: "Container") -> dict[str, typing.Any]: # noqa: ARG002 return {"bound_type": self.bound_type, "self": self} def resolve(self, container: "Container") -> types.T_co | None: diff --git a/modern_di/providers/factory.py b/modern_di/providers/factory.py index 1cad085..aede648 100644 --- a/modern_di/providers/factory.py +++ b/modern_di/providers/factory.py @@ -57,7 +57,9 @@ def _compile_kwargs(self, container: "Container") -> dict[str, typing.Any]: provider = None else: for x in v.args: - provider = container.providers_registry.find_provider(x) + provider = typing.cast( + AbstractProvider[types.T_co] | None, container.providers_registry.find_provider(x) + ) if provider: break diff --git a/pyproject.toml b/pyproject.toml index 7f87b0a..17df53b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,15 +30,11 @@ dev = [ ] lint = [ "ruff", - "mypy", + "ty", "eof-fixer", "typing-extensions", ] -[tool.mypy] -python_version = "3.10" -strict = true - [tool.ruff] fix = true unsafe-fixes = true