Remove mypy python_version pin to support newer numpy stubs#56
Merged
Conversation
mypy was pinned to python_version = "3.11", which made it reject newer numpy stubs that use PEP 695 `type` statements (valid only on 3.12+), failing the 3.12/3.13/3.14 matrix jobs with a syntax error. Drop the pin so mypy targets whichever interpreter it runs under, matching the CI matrix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015tLcNE8iW7jycc6HZMaZx8
Dropping the python_version pin let mypy target 3.12-3.14 in CI, where the numpy stubs are more precise and surfaced two real type errors: - norm.py: the explicit cast() became redundant (warn_redundant_casts) - central_tendencies.py: a return value was inferred as Any (no-any-return) Replace the cast with an annotated assignment and annotate the sorted-modes result. Both narrow the type without an explicit cast, so they satisfy mypy on 3.11 (Any-returning stubs) and 3.12+ (precise stubs) alike. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015tLcNE8iW7jycc6HZMaZx8
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
Removed the
python_version = "3.11"pin from mypy configuration to allow mypy to target the Python interpreter version it runs under, enabling compatibility with newer numpy type stubs that use PEP 695typestatements.Changes
python_version = "3.11"setting from[tool.mypy]configurationtypestatements (only valid in Python 3.12+)Details
This change allows the mypy configuration to be more flexible across the CI matrix while maintaining strict type checking. The removal of the version pin ensures that when mypy runs on Python 3.12+, it can properly validate code using modern type syntax without false positives from outdated stub compatibility checks.
https://claude.ai/code/session_015tLcNE8iW7jycc6HZMaZx8