Skip to content

Swap mypy in favour of ty#630

Open
paddyroddy wants to merge 6 commits into
mainfrom
paddy/issue-572
Open

Swap mypy in favour of ty#630
paddyroddy wants to merge 6 commits into
mainfrom
paddy/issue-572

Conversation

@paddyroddy

Copy link
Copy Markdown
Member

ty is a fast alternative to mypy. Although it has been released for a while now, the pre-commit hook 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 from uv realistically.

Comment thread .prekignore
@@ -0,0 +1 @@
tests/data/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@paddyroddy

Copy link
Copy Markdown
Member Author

@pre-commit.ci seems like it's having a mare

error: Request failed after 3 retries in 6.8s
  Caused by: Failed to fetch: `https://pypi.org/simple/pytest-venv/`
  Caused by: error sending request for url (https://pypi.org/simple/pytest-venv/)
  Caused by: client error (Connect)
  Caused by: dns error
  Caused by: failed to lookup address information: Temporary failure in name resolution

@paddyroddy paddyroddy requested a review from Copilot June 12, 2026 11:50
@paddyroddy paddyroddy self-assigned this Jun 12, 2026
@paddyroddy paddyroddy added enhancement New feature or request p3-medium Medium priority labels Jun 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-mypy pre-commit hook with astral-sh/ty-pre-commit across the root config, template, and test fixture.
  • Add dependency-groups.typechecking and tool.ty configuration to support isolated type-check runs.
  • Update documentation to recommend ty (while still listing mypy as 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.

Comment thread {{cookiecutter.project_slug}}/pyproject.toml
Comment thread tests/data/test_package_generation/pyproject.toml
Comment thread pyproject.toml
Comment thread docs/pages/tutorial.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@paddyroddy paddyroddy requested a review from a team June 12, 2026 12:15
@paddyroddy paddyroddy linked an issue Jun 12, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request p3-medium Medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider replacing mypy with ty

2 participants