ci(pre-commit): pin numpy<2.2 for mypy stub compatibility#1491
Open
dimitri-yatsenko wants to merge 1 commit into
Open
ci(pre-commit): pin numpy<2.2 for mypy stub compatibility#1491dimitri-yatsenko wants to merge 1 commit into
dimitri-yatsenko wants to merge 1 commit into
Conversation
numpy>=2.2 ships type stubs using PEP 695 `type` statements, which mypy rejects while type-checking against python_version=3.10 (the project floor): `numpy/__init__.pyi: error: Type statement is only supported in Python 3.12+`. Pin the mypy hook's stub dependency to numpy<2.2 so the hook passes; runtime numpy is unaffected.
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.
The
mypypre-commit hook fails on a clean checkout:Cause
The hook’s
additional_dependenciespull an unpinnednumpy(currently 2.5.1). numpy ≥2.2 ships type stubs written with PEP 695typestatements. mypy refuses that syntax when type-checking againstpython_version = "3.10"(our support floor, per[tool.mypy]), so the hook errors out before checking any of our code. Bumping mypy (tested through v1.18.2) does not help — the gate is the target version, not the mypy release.Fix
Pin the mypy hook’s stub dependency to
numpy<2.2. This only affects the stubs used for type-checking; runtime numpy is unaffected (unpinned elsewhere). Keeping the target at 3.10 preserves floor coverage rather than masking it by raisingpython_version.Verification
pre-commit run --all-files→ all hooks pass (mypy included).