diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index faedc096..6de349e6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -23,14 +23,14 @@ repos:
rev: v0.24.4
hooks:
- id: toml-sort-fix
- - repo: https://github.com/pre-commit/mirrors-mypy
- rev: v1.20.2
+ - repo: https://github.com/astral-sh/ty-pre-commit
+ rev: v0.0.49
hooks:
- - id: mypy
+ - id: ty
args:
- - --config-file=pyproject.toml
- additional_dependencies:
- - pytest
+ - --group=typechecking
+ - --isolated
+ - --no-default-groups
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.8.3
hooks:
diff --git a/.prekignore b/.prekignore
new file mode 100644
index 00000000..00ca4657
--- /dev/null
+++ b/.prekignore
@@ -0,0 +1 @@
+tests/data/
diff --git a/docs/pages/libraries/jupyter-notebooks.md b/docs/pages/libraries/jupyter-notebooks.md
index 5fb8eb8e..9307689a 100644
--- a/docs/pages/libraries/jupyter-notebooks.md
+++ b/docs/pages/libraries/jupyter-notebooks.md
@@ -32,7 +32,7 @@ more reliably than [black] via [nbQA].
| Name | Short description | 🚦 |
| ---------------- | -------------------------------------------------------------------------------- | :------------------------------------------: |
| `black[jupyter]` | (also `black-jupyter`) [black] with the optional Jupyter extension. | Best |
-| [nbQA] | Recommended for all other linters ([ruff], [isort]) and [mypy]. | Best |
+| [nbQA] | Recommended for all other linters ([ruff], [isort]) and [ty]. | Best |
| [pre-commit] | Has cell output cleanup hooks (if desired). Also found to work well with [nbQA]. | Best |
| `nbqa black` | [black] via [nbQA]. | Good |
@@ -48,7 +48,7 @@ more reliably than [black] via [nbQA].
[nbQA]: https://nbqa.readthedocs.io/en/latest/index.html
[isort]: https://pycqa.github.io/isort
[ruff]: https://github.com/charliermarsh/ruff
-[mypy]: https://mypy.readthedocs.io/en/stable
+[ty]: https://docs.astral.sh/ty/
[pre-commit]: https://github.com/kynan/nbstripout
[jupytext]: https://jupytext.readthedocs.io/en/stable/
diff --git a/docs/pages/linting.md b/docs/pages/linting.md
index 1983cc0a..942179da 100644
--- a/docs/pages/linting.md
+++ b/docs/pages/linting.md
@@ -29,9 +29,10 @@ for some of these.
### Type checking
-| Name | Short description | 🚦 |
-| ---------------------------------------------- | ----------------------------------------------------------------------------- | :-----------------------------------------: |
-| [mypy](https://mypy.readthedocs.io/en/stable/) | Static type checker, won't fail if no typing but will if typing is incorrect. | Best |
+| Name | Short description | 🚦 |
+| ---------------------------------------------- | ----------------------------------------------------------------------------- | :------------------------------------------: |
+| [ty](https://docs.astral.sh/ty/) | Static type checker, fast and rapidly developing. | Best |
+| [mypy](https://mypy.readthedocs.io/en/stable/) | Static type checker, won't fail if no typing but will if typing is incorrect. | Good |
### Dependency checking
diff --git a/docs/pages/tutorial.md b/docs/pages/tutorial.md
index f9a51cc4..49e40324 100644
--- a/docs/pages/tutorial.md
+++ b/docs/pages/tutorial.md
@@ -403,8 +403,8 @@ The package is set-up to use [pre-commit](https://pre-commit.com/), a framework
There is a `.pre-commit-config.yaml` configuration file which you can take a look at.
With this setup `pre-commit` will run a series of fast linters, checks and formatters on the repository on every commit.
-The main tools we recommend are [ruff](https://docs.astral.sh/ruff/), [mypy](https://mypy.readthedocs.io/en/stable/) and [prettier](https://prettier.io/).
-These Git hook scripts can installed locally by running
+The main tools we recommend are [ruff](https://docs.astral.sh/ruff/), [ty](https://docs.astral.sh/ty/) and [prettier](https://prettier.io/).
+These Git hook scripts can be installed locally by running
```sh
pre-commit install
diff --git a/pyproject.toml b/pyproject.toml
index 2ab54710..4e0cedc3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,3 +1,9 @@
+[dependency-groups]
+typechecking = [
+ "pytest",
+ "pytest-venv",
+]
+
[tool.pytest.ini_options]
addopts = [
"--color=yes",
@@ -66,3 +72,9 @@ gh.python = {"3.11" = [
], "3.14" = [
"py314",
]}
+
+[[tool.ty.overrides]]
+include = [
+ "**/src/*/__init__.py",
+]
+rules.unresolved-import = "ignore"
diff --git a/tests/data/test_package_generation/.pre-commit-config.yaml b/tests/data/test_package_generation/.pre-commit-config.yaml
index dd68b7bf..de653007 100644
--- a/tests/data/test_package_generation/.pre-commit-config.yaml
+++ b/tests/data/test_package_generation/.pre-commit-config.yaml
@@ -18,10 +18,14 @@ repos:
rev: v0.24.4
hooks:
- id: toml-sort-fix
- - repo: https://github.com/pre-commit/mirrors-mypy
- rev: v1.20.2
+ - repo: https://github.com/astral-sh/ty-pre-commit
+ rev: v0.0.49
hooks:
- - id: mypy
+ - id: ty
+ args:
+ - --group=typechecking
+ - --isolated
+ - --no-default-groups
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.8.3
hooks:
diff --git a/tests/data/test_package_generation/pyproject.toml b/tests/data/test_package_generation/pyproject.toml
index e5ee29bd..327367af 100644
--- a/tests/data/test_package_generation/pyproject.toml
+++ b/tests/data/test_package_generation/pyproject.toml
@@ -8,11 +8,11 @@ requires = [
[dependency-groups]
dev = [
"build",
- "mypy",
"pre-commit",
"ruff",
"tox",
"twine",
+ "ty",
]
docs = [
"mkdocs-include-markdown-plugin",
@@ -25,6 +25,9 @@ test = [
"pytest",
"pytest-cov",
]
+typechecking = [
+ "pytest",
+]
[project]
authors = [
@@ -67,9 +70,6 @@ paths.source = [
".tox*/*/lib/python*/site-packages",
]
-[tool.mypy]
-explicit_package_bases = true
-
[tool.pytest.ini_options]
addopts = [
"--color=yes",
@@ -148,3 +148,7 @@ gh.python."3.11" = ["py311"]
gh.python."3.12" = ["py312"]
gh.python."3.13" = ["py313"]
gh.python."3.14" = ["py314"]
+
+[tool.ty]
+analysis.respect-type-ignore-comments = false
+terminal.error-on-warning = true
diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml
index dd68b7bf..de653007 100644
--- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml
+++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml
@@ -18,10 +18,14 @@ repos:
rev: v0.24.4
hooks:
- id: toml-sort-fix
- - repo: https://github.com/pre-commit/mirrors-mypy
- rev: v1.20.2
+ - repo: https://github.com/astral-sh/ty-pre-commit
+ rev: v0.0.49
hooks:
- - id: mypy
+ - id: ty
+ args:
+ - --group=typechecking
+ - --isolated
+ - --no-default-groups
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.8.3
hooks:
diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml
index cdc1ced8..433e5d89 100644
--- a/{{cookiecutter.project_slug}}/pyproject.toml
+++ b/{{cookiecutter.project_slug}}/pyproject.toml
@@ -8,11 +8,11 @@ requires = [
[dependency-groups]
dev = [
"build",
- "mypy",
"pre-commit",
"ruff",
"tox",
"twine",
+ "ty",
]
docs = [
"mkdocs-include-markdown-plugin",
@@ -25,6 +25,9 @@ test = [
"pytest",
"pytest-cov",
]
+typechecking = [
+ "pytest",
+]
[project]
authors = [
@@ -69,9 +72,6 @@ paths.source = [
".tox*/*/lib/python*/site-packages",
]
-[tool.mypy]
-explicit_package_bases = true
-
[tool.pytest.ini_options]
addopts = [
"--color=yes",
@@ -154,3 +154,7 @@ env.docs = {commands = [
) %}
gh.python."3.{{python_version}}" = ["py3{{python_version}}"]
{%- endfor %}
+
+[tool.ty]
+analysis.respect-type-ignore-comments = false
+terminal.error-on-warning = true