summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-07-28 16:26:35 +0100
committerYobmod <yobmod@gmail.com>2021-07-28 16:26:35 +0100
commit28fdd30a579362a1121fa7e81d8051098b31f2d1 (patch)
tree398ac4b11472045a6b084e2e4f92e1fcda751b5a /git
parent77a77695b487bf287a5f488ebc7ceadd96e692ae (diff)
downloadgitpython-28fdd30a579362a1121fa7e81d8051098b31f2d1.tar.gz
Fix SymbolicReference reference typing
Diffstat (limited to 'git')
-rw-r--r--git/refs/head.py2
-rw-r--r--git/refs/symbolic.py6
-rw-r--r--git/repo/base.py5
3 files changed, 7 insertions, 6 deletions
diff --git a/git/refs/head.py b/git/refs/head.py
index 338efce9..4b9bf33c 100644
--- a/git/refs/head.py
+++ b/git/refs/head.py
@@ -142,7 +142,7 @@ class Head(Reference):
flag = "-D"
repo.git.branch(flag, *heads)
- def set_tracking_branch(self, remote_reference: 'RemoteReference') -> 'Head':
+ def set_tracking_branch(self, remote_reference: Union['RemoteReference', None]) -> 'Head':
"""
Configure this branch to track the given remote reference. This will alter
this branch's configuration accordingly.
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py
index 0e9dad5c..9a5a4479 100644
--- a/git/refs/symbolic.py
+++ b/git/refs/symbolic.py
@@ -28,6 +28,7 @@ from git.types import Commit_ish, PathLike, TBD, Literal
if TYPE_CHECKING:
from git.repo import Repo
+ from git.refs import Reference
T_References = TypeVar('T_References', bound='SymbolicReference')
@@ -356,8 +357,9 @@ class SymbolicReference(object):
return self
# aliased reference
- reference = property(_get_reference, set_reference, doc="Returns the Reference we point to")
- ref: Union[Commit_ish] = reference # type: ignore # Union[str, Commit_ish, SymbolicReference]
+ reference: Union[Commit_ish, 'Reference'] = property( # type: ignore
+ _get_reference, set_reference, doc="Returns the Reference we point to")
+ ref = reference
def is_valid(self):
"""
diff --git a/git/repo/base.py b/git/repo/base.py
index f8a1689a..74f27b2e 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -422,7 +422,7 @@ class Repo(object):
def create_head(self, path: PathLike, commit: str = 'HEAD',
force: bool = False, logmsg: Optional[str] = None
- ) -> 'SymbolicReference':
+ ) -> 'Head':
"""Create a new head within the repository.
For more documentation, please see the Head.create method.
@@ -788,9 +788,8 @@ class Repo(object):
return proc.replace("\\\\", "\\").replace('"', "").split("\n")
@property
- def active_branch(self) -> 'SymbolicReference':
+ def active_branch(self) -> 'HEAD':
"""The name of the currently active branch.
-
:return: Head to the active branch"""
return self.head.reference