Run mypy on the CI Python version matrix - #22
Open
bjmorgan wants to merge 1 commit into
Open
Conversation
Remove the python_version pin from the mypy configuration and move the type-check step from the lint job into the test matrix. Pinning mypy to 3.11 semantics while running under a newer interpreter made mypy analyse installed third-party packages built for that newer interpreter with the older syntax rules; numpy_typing_compat legitimately uses 3.12+ syntax in such environments, so mypy failed before reaching the package code. With the pin removed, mypy defaults to the interpreter it runs under, so each matrix environment (3.11 to 3.14) type-checks its own semantics against its own installed stubs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mypy lattice_mccurrently fails in any environment newer than Python 3.11 with an error inside the third-partynumpy_typing_compatstubs ("Type statement is only supported in Python 3.12 and greater"). The cause is thepython_version = "3.11"pin in[tool.mypy]: mypy applied 3.11 syntax rules to packages installed for a newer interpreter, and those packages legitimately use 3.12+ syntax on newer Pythons. The CI lint job (Python 3.13) hits exactly this mismatch.Changes
python_versionpin from[tool.mypy]inpyproject.toml, so mypy defaults to the interpreter it runs under and always checks semantics consistent with the installed environment.lintjob into thetestmatrix job, so mypy runs under each supported version (3.11-3.14) with the correspondingly installed dependencies. This is what genuinely verifies 3.11 semantics, rather than emulating them from a newer environment. Thelintjob retains ruff.Verified locally (Python 3.12):
mypy lattice_mcpasses with the pin removed, and the full test suite passes.