Skip to content

Commit c956a4e

Browse files
committed
Swap out mypy for ty in code
1 parent 4b32d34 commit c956a4e

8 files changed

Lines changed: 44 additions & 22 deletions

File tree

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ repos:
2323
rev: v0.24.4
2424
hooks:
2525
- id: toml-sort-fix
26-
- repo: https://github.com/pre-commit/mirrors-mypy
27-
rev: v1.20.2
26+
- repo: https://github.com/astral-sh/ty-pre-commit
27+
rev: v0.0.49
2828
hooks:
29-
- id: mypy
29+
- id: ty
3030
args:
31-
- --config-file=pyproject.toml
32-
additional_dependencies:
33-
- pytest
31+
- --group=typechecking
32+
- --isolated
33+
- --no-default-groups
3434
- repo: https://github.com/rbubley/mirrors-prettier
3535
rev: v3.8.3
3636
hooks:

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
[dependency-groups]
2+
typechecking = [
3+
"pytest",
4+
"pytest-venv",
5+
]
6+
17
[tool.pytest.ini_options]
28
addopts = [
39
"--color=yes",

tests/data/test_package_generation/.pre-commit-config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ repos:
1818
rev: v0.24.4
1919
hooks:
2020
- id: toml-sort-fix
21-
- repo: https://github.com/pre-commit/mirrors-mypy
22-
rev: v1.20.2
21+
- repo: https://github.com/astral-sh/ty-pre-commit
22+
rev: v0.0.49
2323
hooks:
24-
- id: mypy
24+
- id: ty
25+
args:
26+
- --group=typechecking
27+
- --isolated
28+
- --no-default-groups
2529
- repo: https://github.com/rbubley/mirrors-prettier
2630
rev: v3.8.3
2731
hooks:

tests/data/test_package_generation/pyproject.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ requires = [
88
[dependency-groups]
99
dev = [
1010
"build",
11-
"mypy",
1211
"pre-commit",
1312
"ruff",
1413
"tox",
1514
"twine",
15+
"ty",
1616
]
1717
docs = [
1818
"mkdocs-include-markdown-plugin",
@@ -25,6 +25,9 @@ test = [
2525
"pytest",
2626
"pytest-cov",
2727
]
28+
typechecking = [
29+
"pytest",
30+
]
2831

2932
[project]
3033
authors = [
@@ -67,9 +70,6 @@ paths.source = [
6770
".tox*/*/lib/python*/site-packages",
6871
]
6972

70-
[tool.mypy]
71-
explicit_package_bases = true
72-
7373
[tool.pytest.ini_options]
7474
addopts = [
7575
"--color=yes",
@@ -148,3 +148,7 @@ gh.python."3.11" = ["py311"]
148148
gh.python."3.12" = ["py312"]
149149
gh.python."3.13" = ["py313"]
150150
gh.python."3.14" = ["py314"]
151+
152+
[tool.ty]
153+
analysis.respect-type-ignore-comments = false
154+
terminal.error-on-warning = true

tests/data/test_package_generation/src/cookiecutter_test/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""cookiecutter_test package."""
22

3-
from ._version import __version__ # noqa: F401
3+
from ._version import __version__ # noqa: F401 # ty: ignore[unresolved-import]
44

55

66
def example_function(argument: str, keyword_argument: str = "default") -> str:

{{cookiecutter.project_slug}}/.pre-commit-config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ repos:
1818
rev: v0.24.4
1919
hooks:
2020
- id: toml-sort-fix
21-
- repo: https://github.com/pre-commit/mirrors-mypy
22-
rev: v1.20.2
21+
- repo: https://github.com/astral-sh/ty-pre-commit
22+
rev: v0.0.49
2323
hooks:
24-
- id: mypy
24+
- id: ty
25+
args:
26+
- --group=typechecking
27+
- --isolated
28+
- --no-default-groups
2529
- repo: https://github.com/rbubley/mirrors-prettier
2630
rev: v3.8.3
2731
hooks:

{{cookiecutter.project_slug}}/pyproject.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ requires = [
88
[dependency-groups]
99
dev = [
1010
"build",
11-
"mypy",
1211
"pre-commit",
1312
"ruff",
1413
"tox",
1514
"twine",
15+
"ty",
1616
]
1717
docs = [
1818
"mkdocs-include-markdown-plugin",
@@ -25,6 +25,9 @@ test = [
2525
"pytest",
2626
"pytest-cov",
2727
]
28+
typechecking = [
29+
"pytest",
30+
]
2831

2932
[project]
3033
authors = [
@@ -69,9 +72,6 @@ paths.source = [
6972
".tox*/*/lib/python*/site-packages",
7073
]
7174

72-
[tool.mypy]
73-
explicit_package_bases = true
74-
7575
[tool.pytest.ini_options]
7676
addopts = [
7777
"--color=yes",
@@ -154,3 +154,7 @@ env.docs = {commands = [
154154
) %}
155155
gh.python."3.{{python_version}}" = ["py3{{python_version}}"]
156156
{%- endfor %}
157+
158+
[tool.ty]
159+
analysis.respect-type-ignore-comments = false
160+
terminal.error-on-warning = true

{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""{{cookiecutter.package_name}} package."""
22

3-
from ._version import __version__ # noqa: F401
3+
from ._version import __version__ # noqa: F401 # ty: ignore[unresolved-import]
44

55

66
def example_function(argument: str, keyword_argument: str = "default") -> str:

0 commit comments

Comments
 (0)