From edf68accaf2591065c24b85899d67f1bade656db Mon Sep 17 00:00:00 2001 From: Artur Shiriev Date: Fri, 13 Mar 2026 09:44:52 +0300 Subject: [PATCH] migrate to ty --- AGENTS.md | 4 ++-- Justfile | 4 ++-- db_retry/connections.py | 2 +- db_retry/retry.py | 2 +- pyproject.toml | 6 +----- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index f3de4a5..c85a70e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,7 +20,7 @@ The library is built with modern Python practices (3.13+) and uses type hints ex - **uv** for package management and building - **Docker** for development and testing environments - **pytest** for testing -- **ruff** and **mypy** for linting and type checking +- **ruff** and **ty** for linting and type checking ## Project Structure @@ -112,7 +112,7 @@ The library can be configured using environment variables: ## Development Conventions -1. **Type Safety**: Strict mypy checking is enforced +1. **Type Safety**: Strict ty checking is enforced 2. **Code Style**: Ruff is used for linting with specific rules configured 3. **Testing**: All functionality should have corresponding tests 4. **Async/Await**: All database operations are asynchronous diff --git a/Justfile b/Justfile index b9c0246..b446304 100644 --- a/Justfile +++ b/Justfile @@ -20,13 +20,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 publish: rm -rf dist diff --git a/db_retry/connections.py b/db_retry/connections.py index d02a7e9..4198b43 100644 --- a/db_retry/connections.py +++ b/db_retry/connections.py @@ -20,7 +20,7 @@ def build_connection_factory( url: sqlalchemy.URL, timeout: float, ) -> typing.Callable[[], typing.Awaitable["ConnectionType"]]: - connect_args: typing.Final[dict[str, typing.Any]] = PGDialect_asyncpg().create_connect_args(url)[1] # type: ignore[no-untyped-call] + connect_args: typing.Final[dict[str, typing.Any]] = PGDialect_asyncpg().create_connect_args(url)[1] raw_target_session_attrs: typing.Final[str | None] = connect_args.pop("target_session_attrs", None) target_session_attrs: typing.Final[SessionAttribute | None] = ( SessionAttribute(raw_target_session_attrs) if raw_target_session_attrs else None diff --git a/db_retry/retry.py b/db_retry/retry.py index c1e6fb0..0e46db7 100644 --- a/db_retry/retry.py +++ b/db_retry/retry.py @@ -33,7 +33,7 @@ def postgres_retry[**P, T]( wait=tenacity.wait_exponential_jitter(), retry=tenacity.retry_if_exception(_retry_handler), reraise=True, - before=tenacity.before_log(logger, logging.DEBUG), + before=tenacity.before_log(logger, logging.DEBUG), # ty: ignore[invalid-argument-type] ) @functools.wraps(func) async def wrapped_method(*args: P.args, **kwargs: P.kwargs) -> T: diff --git a/pyproject.toml b/pyproject.toml index 2697bd0..9f32d2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ dev = [ ] lint = [ "ruff", - "mypy", + "ty", "eof-fixer", "asyncpg-stubs", ] @@ -49,10 +49,6 @@ build-backend = "uv_build" module-name = "db_retry" module-root = "" -[tool.mypy] -python_version = "3.13" -strict = true - [tool.ruff] fix = false unsafe-fixes = true