Skip to content

Replace mypy pre-commit hook with ty - #671

Draft
observingClouds with Copilot wants to merge 1 commit into
mainfrom
copilot/replace-mypy-with-ty-hook
Draft

Replace mypy pre-commit hook with ty#671
observingClouds with Copilot wants to merge 1 commit into
mainfrom
copilot/replace-mypy-with-ty-hook

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown

Describe your changes

Replaces mypy with Astral ty in pre-commit while keeping static type-checking in the lint pipeline. Updates project agent guidance and changelog to reflect the tool migration.

  • Hook migration
    • .pre-commit-config.yaml: replace pre-commit/mirrors-mypy hook with astral-sh/ty-pre-commit (id: ty).
  • Repo docs alignment
    • AGENTS.md: update lint command comment (mypyty).
    • CHANGELOG.md: add unreleased Maintenance entry for this migration.
  • Behavioral deltas that cannot be matched 1:1
    • ty hook is configured project-wide by design (not filename-driven like typical mypy hook usage).
    • mypy hook additional_dependencies for types-* stubs has no direct equivalent in this hook configuration.
    • Diagnostic output is not parity-compatible; ty reports a different set of findings.
- repo: https://github.com/astral-sh/ty-pre-commit
  rev: v0.0.49
  hooks:
    - id: ty
      description: Check for type errors

No new runtime/package dependencies were introduced in project metadata.

Issue Link

Handled by system automation.

Type of change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📖 Documentation (Addition or improvements to documentation)

Checklist before requesting a review

  • My branch is up-to-date with the target branch - if not update your fork with the changes from the target branch (use pull with --rebase option if possible).
  • I have performed a self-review of my code
  • For any new/modified functions/classes I have added docstrings that clearly describe its purpose, expected inputs and returned values
  • I have placed in-line comments to clarify the intent of any hard-to-understand passages of my code
  • I have updated the README to cover introduced code changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have given the PR a name that clearly describes the change, written in imperative form (context).
  • I have requested a reviewer and an assignee (assignee is responsible for merging). This applies only if you have write access to the repo, otherwise feel free to tag a maintainer to add a reviewer and assignee.

Checklist for reviewers

Each PR comes with its own improvements and flaws. The reviewer should check the following:

  • the code is readable
  • the code is well tested
  • the code is documented (including return types and parameters)
  • the code is easy to maintain

Author checklist after completed review

  • I have added a line to the CHANGELOG describing this change, in a section
    reflecting type of change (add section where missing):
    • added: when you have added new functionality
    • changed: when default behaviour of the code has been changed
    • fixes: when your contribution fixes a bug
    • maintenance: when your contribution is relates to repo maintenance, e.g. CI/CD or documentation

Checklist for assignee

  • PR is up to date with the base branch
  • the tests pass
  • (if the PR is not just maintenance/bugfix) the PR is assigned to the next milestone. If it is not, propose it for a future milestone.
  • author has added an entry to the changelog (and designated the change as added, changed, fixed or maintenance)
  • Once the PR is ready to be merged, squash commits and merge the PR.

@GiGiKoneti

Copy link
Copy Markdown
Contributor

@sadamov
Since the new ty hook reports type errors on the core codebase due to early preview limitations with libraries like PyTorch and xarray, shouldnt we stick with mypy for now?

@observingClouds

Copy link
Copy Markdown
Contributor

Hi @GiGiKoneti this was really just a test of mine to both test if and how much ty would speed up the pre-commit hooks and if it is able to check the same types. As you can see there are still quite some issues and I haven't had a chance to look at the timing yet. Looking at the errors that ty surfaces there might be something to fix in the future as well. IMHO we should stick with mypy for now and have that really set up for the entire codebase. 30 sec for the entire pre-commit hooks is however a rather long time and we might want to explore e.g. ty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants