Skip to content

Replace mypy type-check gate with ty (astral-sh) - #1

Merged
GiGiKoneti merged 1 commit into
GiGiKoneti:chore/type-hint-coveragefrom
sadamov:chore/ty-type-checker
Jul 15, 2026
Merged

Replace mypy type-check gate with ty (astral-sh)#1
GiGiKoneti merged 1 commit into
GiGiKoneti:chore/type-hint-coveragefrom
sadamov:chore/ty-type-checker

Conversation

@sadamov

@sadamov sadamov commented Jul 13, 2026

Copy link
Copy Markdown

Describe your changes

Targets mllam#673 (not main): replaces the mypy type-check gate that mllam#673 introduces with ty (astral-sh).

  • Swap the mirrors-mypy pre-commit hook and [tool.mypy] config for ty. Unlike mypy with ignore_missing_imports, ty resolves imports against the project venv, so it type-checks against real torch/lightning/xarray types.
  • Migrate the mypy # type: ignore[...] comments to explicit # ty: ignore[<rule>] (ty does not honour mypy's code-specific directives); a few lines are rewrapped where ty's longer rule names would exceed the 80-char limit.
  • [tool.ty] downgrades the noisy possibly-missing-submodule rule and pins the environment to .venv.
  • ty runs as a local pre-commit hook and in the install-and-test CI job after uv sync; it is skipped in the deps-less linting CI job (it needs the venv to resolve imports).
  • mypy and the types-* stub dev deps are dropped from pyproject.toml and uv.lock.

No dependencies at runtime.

Two coordination points:

Issue Link

refs mllam#670

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)

(Maintenance / CI-CD change - the Type-of-change list above has no maintenance option; see the CHANGELOG Maintenance entry.)

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.

@sadamov
sadamov marked this pull request as ready for review July 13, 2026 13:18
@sadamov
sadamov force-pushed the chore/ty-type-checker branch 2 times, most recently from 9c00930 to cd176fe Compare July 13, 2026 14:11
Swap the mypy pre-commit hook and [tool.mypy] config for ty, which resolves
imports against the project venv and checks type correctness more thoroughly
than mypy did with ignore_missing_imports. Migrate the mypy
`# type: ignore[...]` comments to `# ty: ignore[<rule>]` (ty does not honour
mypy's code-specific directives), rewrapping the few lines where ty's longer
rule names would exceed the 80-char limit. Add [tool.ty] config downgrading
the noisy possibly-missing-submodule rule and pointing ty at .venv.

ty runs as a local pre-commit hook and in the install-and-test CI job (after
uv sync); it is skipped in the deps-less linting CI job. mypy and the types-*
stub dev deps are dropped from pyproject and uv.lock.

Annotation-coverage enforcement (mypy's disallow_untyped_defs) is not offered
by ty and moves to ruff's flake8-annotations (ANN) rules in mllam#614.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sadamov
sadamov force-pushed the chore/ty-type-checker branch from cd176fe to db756b3 Compare July 13, 2026 14:16
@GiGiKoneti
GiGiKoneti merged commit 7272032 into GiGiKoneti:chore/type-hint-coverage Jul 15, 2026
@sadamov
sadamov deleted the chore/ty-type-checker branch July 15, 2026 07:01
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.

2 participants