diff --git a/pyproject.toml b/pyproject.toml index 4ce190b..2d27860 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -128,11 +128,5 @@ report.fail_under = 63 html.show_contexts = true html.skip_covered = false -[tool.mypy] -show_error_codes = true -strict = true -overrides = [ - { module = [ - "pre_commit.*", - ], ignore_missing_imports = true }, -] +[tool.ty] +environment.python-version = "3.14" diff --git a/src/pre_commit_uv/__init__.py b/src/pre_commit_uv/__init__.py index abe1034..0a7f4d8 100644 --- a/src/pre_commit_uv/__init__.py +++ b/src/pre_commit_uv/__init__.py @@ -5,6 +5,10 @@ # only import built-ins at top level to avoid interpreter startup overhead import os import sys +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from collections.abc import Sequence _original_main = None @@ -33,7 +37,7 @@ def _patch() -> None: if _is_calling_pre_commit() and os.environ.get("DISABLE_PRE_COMMIT_UV_PATCH") is None: from pre_commit import main # noqa: PLC0415 - _original_main, main.main = main.main, _new_main + _original_main, main.main = main.main, _new_main # ty: ignore[invalid-assignment] if "--version" in sys.argv: from importlib.metadata import version as _metadata_version # noqa: PLC0415 @@ -47,16 +51,14 @@ def _patch() -> None: ) -def _new_main(argv: list[str] | None = None) -> int: +def _new_main(argv: Sequence[str] | None = None) -> int: # imports applied locally to avoid patching import overhead cost from functools import cache # noqa: PLC0415 - from typing import TYPE_CHECKING, cast # noqa: PLC0415 + from typing import cast # noqa: PLC0415 from pre_commit.languages import python # noqa: PLC0415 if TYPE_CHECKING: - from collections.abc import Sequence # noqa: PLC0415 - from pre_commit.prefix import Prefix # noqa: PLC0415 def _install_environment( @@ -126,11 +128,11 @@ def _version_info(exe: str) -> str: prog = 'import sys;print(".".join(str(p) for p in sys.version_info[0:3]))' try: - return cast("str", cmd_output(exe, "-S", "-c", prog)[1].strip()) + return cmd_output(exe, "-S", "-c", prog)[1].strip() except CalledProcessError: return f"<>" - python.install_environment = _install_environment + python.install_environment = _install_environment # ty: ignore[invalid-assignment] python._version_info = _version_info # noqa: SLF001 assert _original_main is not None # noqa: S101 return cast("int", _original_main(argv)) diff --git a/tox.toml b/tox.toml index b85e6da..05a20cc 100644 --- a/tox.toml +++ b/tox.toml @@ -53,8 +53,8 @@ commands = [ [env.type] description = "run type check on code base" -deps = [ "mypy==1.18.2" ] -commands = [ [ "mypy", "src" ], [ "mypy", "tests" ] ] +deps = [ "ty>=0.0.17" ] +commands = [ [ "ty", "check", "--output-format", "concise", "--error-on-warning", "." ] ] [env.dev] description = "generate a DEV environment"