Skip to content

Conversation

emmanuel-ferdman
Copy link
Contributor

PR Summary

This PR fixes mypy errors introduced in v3.1.45 where code like repo.head.ref.checkout() fails type checking even though it works at runtime. The issue is that SymbolicReference.reference was typed to return SymbolicReference, but it actually returns Reference subclasses that have methods like checkout() and tracking_branch(). Changed the return type annotation from SymbolicReference to Reference and added an explicit cast in _get_reference() to match what actually happens at runtime. This is a type-only change with no behavioral impact.

Fixes #2066.

@Byron
Copy link
Member

Byron commented Sep 30, 2025

Thanks a lot, looks good to me!

Besides that, we do have mypi type checks, but it seems like they are advisory only and can't fail CI.

@Byron Byron merged commit 963b6f8 into gitpython-developers:main Sep 30, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect return type hint in SymbolicReference.reference leads to mypy errors
2 participants