Skip to content

Remove mypy python_version pin to support newer numpy stubs#56

Merged
OVVO-Financial merged 2 commits into
mainfrom
claude/compassionate-cannon-s55vi5
Jun 22, 2026
Merged

Remove mypy python_version pin to support newer numpy stubs#56
OVVO-Financial merged 2 commits into
mainfrom
claude/compassionate-cannon-s55vi5

Conversation

@OVVO-Financial

Copy link
Copy Markdown
Owner

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 695 type statements.

Changes

  • Removed the hardcoded python_version = "3.11" setting from [tool.mypy] configuration
  • Added explanatory comment documenting why the pin was removed:
    • The CI matrix runs mypy across Python 3.11-3.14
    • Pinning to 3.11 caused mypy to reject newer numpy stubs using PEP 695 type statements (only valid in Python 3.12+)
    • Unpinned mypy now correctly targets the interpreter version it runs under

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

claude added 2 commits June 22, 2026 16:36
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
@OVVO-Financial OVVO-Financial merged commit db2e3d1 into main Jun 22, 2026
4 checks passed
@OVVO-Financial OVVO-Financial deleted the claude/compassionate-cannon-s55vi5 branch June 22, 2026 17:14
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