Skip to content

Commit 5d66ac5

Browse files
authored
feat!: replace mypy with ty (#321)
1 parent cf60a21 commit 5d66ac5

File tree

4 files changed

+24
-39
lines changed

4 files changed

+24
-39
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ A modern [Copier template](https://github.com/copier-org/copier) for scaffolding
1414
- 📦 Packaging and dependency management with [uv](https://github.com/astral-sh/uv)
1515
- 🚚 Installing from and publishing to [PyPI](https://pypi.org/)
1616
- ⚡️ Task running with [Poe the Poet](https://github.com/nat-n/poethepoet)
17-
- 💅 Code formatting with [Ruff](https://github.com/charliermarsh/ruff)
18-
- ✅ Code linting with [Pre-commit](https://pre-commit.com/), [Mypy](https://github.com/python/mypy), and [Ruff](https://github.com/charliermarsh/ruff)
17+
- 💅 Code formatting with [ruff](https://github.com/astral-sh/ruff)
18+
- ✅ Code linting with [pre-commit](https://pre-commit.com/), [ruff](https://github.com/astral-sh/ruff), and [ty](https://github.com/astral-sh/ty)
1919
- 🏷 Optionally follow the [Conventional Commits](https://www.conventionalcommits.org/) standard
2020
- 🚦 Release new versions with [Semantic Versioning](https://semver.org/) and [Keep A Changelog](https://keepachangelog.com/) using [Commitizen](https://github.com/commitizen-tools)
2121
- 💌 Verified commits with [GPG](https://gnupg.org/)
2222
- ♻️ Continuous integration with [GitHub Actions](https://docs.github.com/en/actions) or [GitLab CI/CD](https://docs.gitlab.com/ee/ci/)
2323
- 🧪 Test coverage with [Coverage.py](https://github.com/nedbat/coveragepy)
24-
- 🧰 Dependency updates with [Dependabot](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates)
24+
- 🧰 Dependency updates with [Dependabot](https://docs.github.com/en/code-security/getting-started/dependabot-quickstart-guide)
2525
- 📚 Documentation with [MkDocs](https://github.com/mkdocs/mkdocs)
2626

2727
## ✨ Using

template/.devcontainer/devcontainer.json.jinja

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
},
2626
"vscode": {
2727
"extensions": [
28+
"astral-sh.ty",
2829
"charliermarsh.ruff",
2930
"GitHub.copilot",
3031
"GitHub.copilot-chat",
@@ -35,7 +36,6 @@
3536
"GitLab.gitlab-workflow",
3637
{%- endif %}
3738
"ms-azuretools.vscode-docker",
38-
"ms-python.mypy-type-checker",
3939
"ms-python.python",
4040
"ms-toolsai.jupyter",
4141
"ryanluker.vscode-coverage-gutters",
@@ -68,20 +68,16 @@
6868
"jupyter.kernels.excludePythonEnvironments": [
6969
"/usr/local/bin/python"
7070
],
71-
"mypy-type-checker.importStrategy": "fromEnvironment",
72-
"mypy-type-checker.preferDaemon": true,
7371
"notebook.codeActionsOnSave": {
7472
"notebook.source.fixAll": "explicit",
7573
"notebook.source.organizeImports": "explicit"
7674
},
7775
"notebook.formatOnSave.enabled": true,
7876
"python.defaultInterpreterPath": "/opt/venv/bin/python",
77+
"python.languageServer": "None",
7978
"python.terminal.activateEnvironment": false,
8079
"python.testing.pytestEnabled": true,
8180
"ruff.importStrategy": "fromEnvironment",
82-
{%- if typing == 'strict' %}
83-
"ruff.logLevel": "warning",
84-
{%- endif %}
8581
"terminal.integrated.env.linux": {
8682
"GIT_EDITOR": "code --wait"
8783
},

template/.pre-commit-config.yaml.jinja

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ repos:
7777
require_serial: true
7878
language: system
7979
types_or: [python, pyi]
80-
- id: mypy
81-
name: mypy
82-
entry: mypy
80+
- id: ty
81+
name: ty
82+
entry: ty check
83+
require_serial: true
8384
language: system
84-
types: [python]
85+
types_or: [python, pyi]

template/pyproject.toml.jinja

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ dev = [
4848
"ipykernel (>=6.29.4)",
4949
"ipython (>=8.18.0)",
5050
"ipywidgets (>=8.1.2)",
51-
"mypy (>=1.14.1)",
5251
"mkdocs-material (>=9.5.21)",
5352
{%- if project_type == 'package' %}
5453
"mkdocstrings[python] (>=0.26.2)",
@@ -59,6 +58,7 @@ dev = [
5958
"pytest-mock (>=3.14.0)",
6059
"pytest-xdist (>=3.6.1)",
6160
"ruff (>=0.9.2)",
61+
"ty (>=0.0.5)",
6262
{%- if typing == 'strict' %}
6363
"typeguard (>=4.4.1)",
6464
{%- endif %}
@@ -89,31 +89,6 @@ source = ["src"]
8989
[tool.coverage.xml] # https://coverage.readthedocs.io/en/latest/config.html#xml
9090
output = "reports/coverage.xml"
9191

92-
[tool.mypy] # https://mypy.readthedocs.io/en/latest/config_file.html
93-
junit_xml = "reports/mypy.xml"
94-
{%- if with_fastapi_api %}
95-
plugins = "pydantic.mypy"
96-
{%- endif %}
97-
{%- if typing == 'strict' %}
98-
strict = true
99-
disallow_subclassing_any = false
100-
disallow_untyped_decorators = false
101-
{%- endif %}
102-
ignore_missing_imports = true
103-
pretty = true
104-
show_column_numbers = true
105-
show_error_codes = true
106-
show_error_context = true
107-
warn_unreachable = true
108-
{%- if typing == 'strict' and with_fastapi_api %}
109-
110-
[tool.pydantic-mypy] # https://docs.pydantic.dev/latest/integrations/mypy/#configuring-the-plugin
111-
init_forbid_extra = true
112-
init_typed = true
113-
warn_required_dynamic_aliases = true
114-
warn_untyped_fields = true
115-
{%- endif %}
116-
11792
[tool.pytest.ini_options] # https://docs.pytest.org/en/latest/reference/reference.html#ini-options-ref
11893
addopts = "--color=yes --doctest-modules --exitfirst --failed-first{% if typing == 'strict' %} --strict-config --strict-markers{% endif %} --verbosity=2 --junitxml=reports/pytest.xml"
11994
{%- if typing == 'strict' %}
@@ -158,6 +133,19 @@ max-doc-length = 100
158133

159134
[tool.ruff.lint.pydocstyle]
160135
convention = "numpy"
136+
{%- if project_type == 'package' %}
137+
138+
[tool.ty.environment]
139+
python-platform = "all"
140+
{%- endif %}
141+
142+
[tool.ty.rules]
143+
unused-ignore-comment = "warn"
144+
{%- if typing == 'strict' %}
145+
146+
[tool.ty.terminal]
147+
error-on-warning = true
148+
{%- endif %}
161149

162150
[tool.poe.executor] # https://github.com/nat-n/poethepoet
163151
type = "simple"

0 commit comments

Comments
 (0)