Fix SymbolicReference reference typing · gitpython-developers/GitPython@28fdd30 · GitHub
Skip to content

Commit 28fdd30

Browse files
committed
Fix SymbolicReference reference typing
1 parent 77a7769 commit 28fdd30

4 files changed

Lines changed: 14 additions & 8 deletions

File tree

git/refs/head.py

Lines changed: 1 addition & 1 deletion

git/refs/symbolic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
if TYPE_CHECKING:
3030
from git.repo import Repo
31+
from git.refs import Reference
3132

3233
T_References = TypeVar('T_References', bound='SymbolicReference')
3334

@@ -356,8 +357,9 @@ def set_reference(self, ref, logmsg=None):
356357
return self
357358

358359
# aliased reference
359-
reference = property(_get_reference, set_reference, doc="Returns the Reference we point to")
360-
ref: Union[Commit_ish] = reference # type: ignore # Union[str, Commit_ish, SymbolicReference]
360+
reference: Union[Commit_ish, 'Reference'] = property( # type: ignore
361+
_get_reference, set_reference, doc="Returns the Reference we point to")
362+
ref = reference
361363

362364
def is_valid(self):
363365
"""

git/repo/base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def _to_full_tag_path(path):
422422

423423
def create_head(self, path: PathLike, commit: str = 'HEAD',
424424
force: bool = False, logmsg: Optional[str] = None
425-
) -> 'SymbolicReference':
425+
) -> 'Head':
426426
"""Create a new head within the repository.
427427
For more documentation, please see the Head.create method.
428428
@@ -788,9 +788,8 @@ def ignored(self, *paths: PathLike) -> List[PathLike]:
788788
return proc.replace("\\\\", "\\").replace('"', "").split("\n")
789789

790790
@property
791-
def active_branch(self) -> 'SymbolicReference':
791+
def active_branch(self) -> 'HEAD':
792792
"""The name of the currently active branch.
793-
794793
:return: Head to the active branch"""
795794
return self.head.reference
796795

test/test_refs.py

Lines changed: 7 additions & 2 deletions

0 commit comments

Comments
 (0)