Swap mypy in favour of ty - #630
Conversation
| @@ -0,0 +1 @@ | |||
| tests/data/ | |||
There was a problem hiding this comment.
I am using https://github.com/j178/prek in favour of pre-commit locally. I found that running on the top level was running the hooks in tests/data/test_package_generation which was causing bugs.
|
@pre-commit.ci seems like it's having a mare |
There was a problem hiding this comment.
Pull request overview
This PR updates the cookiecutter template (and its test fixture) to use Astral’s ty type checker instead of mypy, and wires ty into pre-commit so type checking runs consistently in local development and CI.
Changes:
- Replace the
mirrors-mypypre-commit hook withastral-sh/ty-pre-commitacross the root config, template, and test fixture. - Add
dependency-groups.typecheckingandtool.tyconfiguration to support isolated type-check runs. - Update documentation to recommend
ty(while still listingmypyas an alternative).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
tests/data/test_package_generation/pyproject.toml |
Updates fixture dependencies/config from mypy to ty and adds typechecking group/config. |
tests/data/test_package_generation/.pre-commit-config.yaml |
Switches fixture pre-commit type checking hook from mypy to ty. |
pyproject.toml |
Adds a typechecking dependency group and ty overrides for this repository. |
docs/pages/tutorial.md |
Updates recommended tooling to reference ty instead of mypy. |
docs/pages/linting.md |
Promotes ty as the preferred type checker and downgrades mypy to “Good”. |
docs/pages/libraries/jupyter-notebooks.md |
Updates notebook linting guidance to reference ty instead of mypy. |
{{cookiecutter.project_slug}}/pyproject.toml |
Updates template dev dependencies/config from mypy to ty and adds typechecking group/config. |
{{cookiecutter.project_slug}}/.pre-commit-config.yaml |
Switches template pre-commit type checking hook from mypy to ty. |
.prekignore |
Adds ignore rules for prek users (separate from pre-commit’s own excludes). |
.pre-commit-config.yaml |
Switches this repo’s pre-commit type checking hook from mypy to ty. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
samcunliffe
left a comment
There was a problem hiding this comment.
Looks good to me! Nice and complete. Website looks correct too.
Is this a two-reviewers jobby? Pinging someone else from @UCL-ARC/collaborations-python-tooling
Having said that it's been open for more than 1 month. So I'd say any objectors would have made themselves known by now. |
matt-graham
left a comment
There was a problem hiding this comment.
From my perspective also happy for this to go in. Agree that the additional jeopardy of recommending ty given Astral ownership situation is minimal if we are already recommending uv. Have added a small suggestion to record the clarification about .prekignore file added in your review comment as a comment in file (seems like from documentation .prekignore follows .gitignore syntax and so should support # comments).
Co-authored-by: Matt Graham <matthew.m.graham@gmail.com>
Just realised our very own @dstansby made an issue on this pre-commit-ci/issues#249 |
|
I'm going to merge. Hopefully that @pre-commit-ci either fixes itself. If not we can raise a new issue to tackle it. |
tyis a fast alternative tomypy. Although it has been released for a while now, thepre-commithook has only just been released. We've used this successfully in GLASS glass-dev/glass#1133 and I've used it in SLEPLET astro-informatics/sleplet#489. It is being rapidly developed so will only get better. I know Astral sold out, but I doubt we're going to move fromuvrealistically.