Skip to content

Conversation

@max-sixty
Copy link
Collaborator

Summary

  • Upgrade mypy from 1.15 to 1.17.1 in CI
  • Fix all 65 mypy errors to achieve zero errors
  • All changes are minimal type annotation improvements without logic modifications

Changes

Core Library Fixes (10 files)

  • Remove obsolete type: ignore comments
  • Fix pandas MultiIndex type compatibility with list conversions
  • Resolve dictionary key type issues (Hashable vs str)
  • Add type annotations for better type inference
  • Correct Variable.data setter override placement

Test File Fixes (10 files)

  • Update scipy/pandas interface compatibility
  • Add appropriate type: ignore comments for external library issues
  • Fix variable redefinition issues

Testing

  • ✅ All mypy checks pass: Success: no issues found in 193 source files
  • ✅ Basic functionality tested locally
  • ✅ Import and MultiIndex operations work correctly

🤖 Generated with Claude Code

- Update mypy from 1.15 to 1.17.1 in CI requirements
- Fix 65 mypy errors across 20 files to achieve zero errors
- Key fixes:
  - Remove obsolete type: ignore comments
  - Fix pandas MultiIndex type compatibility (list conversions)
  - Resolve dictionary key type issues (Hashable vs str)
  - Add type annotations for better type inference
  - Fix scipy/pandas interface compatibility in tests
  - Correct Variable.data setter override placement

All changes are minimal type annotation improvements without logic modifications.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions bot added topic-indexing topic-CF conventions topic-groupby topic-cftime CI Continuous Integration tools dependencies Pull requests that update a dependency file labels Sep 3, 2025
max-sixty and others added 10 commits September 3, 2025 16:37
Keep pd.Index objects instead of converting to lists to preserve dtype behavior in MultiIndex levels.
CI environment may report some type: ignore comments as unused while they're needed locally. Adding unused-ignore to suppress these warnings.
- Added types-requests to CI dependencies to provide typing for requests module
- Removed type: ignore comments that were showing as unused both locally and in CI
- Kept only the type: ignore that are actually necessary (one in test_plot.py)
The CI environment showed different mypy behavior than local environment,
requiring us to keep these type: ignore comments with unused-ignore flag
- Add type: ignore for indexes.py indexing operation
- Add type: ignore for alignment.py return type issues
- Add type: ignore for cftimeindex.py shift method override
- Change level_coords_dtype type from dict[str, Any] to dict[Hashable | None, Any]
- This matches pandas MultiIndex.names which can be Hashable or None
- Remove unnecessary str() conversions added in previous commit
- Remove obsolete type: ignore comment and TODO that questioned if Hashables are ok (they are)

This is a cleaner solution that better reflects the actual pandas API.
- Changed return type from list[str] | None to list[Hashable | None] | None
- This matches pandas MultiIndex.names actual type (list[Hashable | None])
- Removed unnecessary str() conversion that was losing type information
- Now returns list(index.names) directly, preserving the correct types
@max-sixty max-sixty enabled auto-merge (squash) September 4, 2025 02:31
@max-sixty max-sixty merged commit a13a255 into pydata:main Sep 4, 2025
36 checks passed
@max-sixty max-sixty deleted the mypy-upgrade branch September 4, 2025 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Continuous Integration tools dependencies Pull requests that update a dependency file topic-CF conventions topic-cftime topic-groupby topic-indexing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant