FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix type hint for `SymbolicReference.reference` property by emmanuel-ferdman · Pull Request #2074 · gitpython-developers/GitPython · GitHub

Fix type hint for SymbolicReference.reference property - #2074

Merged
Byron merged 1 commit into
gitpython-developers:mainfrom
emmanuel-ferdman:main
Sep 30, 2025
Merged

Fix type hint for SymbolicReference.reference property#2074
Byron merged 1 commit into
gitpython-developers:mainfrom
emmanuel-ferdman:main

Conversation

Copy link
Copy Markdown
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.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>

Byron commented Sep 30, 2025

Copy link
Copy Markdown
Member

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 merged commit 963b6f8 into gitpython-developers:main Sep 30, 2025
27 checks passed
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

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


Back | FazBrowse Home | New Git URL