summaryrefslogtreecommitdiff
path: root/git/refs/symbolic.py
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-07-28 17:39:01 +0100
committerYobmod <yobmod@gmail.com>2021-07-28 17:39:01 +0100
commit5b880c0e98e41276de9fc498b25727c149cfcc40 (patch)
tree06ff2fdf44ef5a655af397ecf369d45d42878590 /git/refs/symbolic.py
parent7cf30c1cf4a6494916a162983bdb439388d59ff3 (diff)
downloadgitpython-5b880c0e98e41276de9fc498b25727c149cfcc40.tar.gz
Fix more missing types in Symbolic.py
Diffstat (limited to 'git/refs/symbolic.py')
-rw-r--r--git/refs/symbolic.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py
index 4919ea83..2e8544d3 100644
--- a/git/refs/symbolic.py
+++ b/git/refs/symbolic.py
@@ -25,7 +25,7 @@ from git.types import Commit_ish, PathLike, TBD, Literal
if TYPE_CHECKING:
from git.repo import Repo
- from git.refs import Reference
+ from git.refs import Reference, Head, HEAD, TagReference, RemoteReference
T_References = TypeVar('T_References', bound='SymbolicReference')
@@ -141,13 +141,13 @@ class SymbolicReference(object):
intermediate references as required
:param repo: the repository containing the reference at ref_path"""
while True:
- hexsha, ref_path = cls._get_ref_info(repo, ref_path)
+ hexsha, _ref_path_out = cls._get_ref_info(repo, ref_path)
if hexsha is not None:
return hexsha
# END recursive dereferencing
@classmethod
- def _get_ref_info_helper(cls, repo: 'Repo', ref_path: PathLike):
+ def _get_ref_info_helper(cls, repo: 'Repo', ref_path: PathLike) -> Union[Tuple[str, None], Tuple[None, PathLike]]:
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
rela_path points to, or None. target_ref_path is the reference we
point to, or None"""
@@ -186,13 +186,14 @@ class SymbolicReference(object):
raise ValueError("Failed to parse reference information from %r" % ref_path)
@classmethod
- def _get_ref_info(cls, repo: 'Repo', ref_path: PathLike):
+ def _get_ref_info(cls, repo: 'Repo', ref_path: PathLike
+ ) -> Union[Tuple[str, None], Tuple[None, PathLike]]:
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
rela_path points to, or None. target_ref_path is the reference we
point to, or None"""
return cls._get_ref_info_helper(repo, ref_path)
- def _get_object(self):
+ def _get_object(self) -> Commit_ish:
"""
:return:
The object our ref currently refers to. Refs can be cached, they will
@@ -201,7 +202,7 @@ class SymbolicReference(object):
# Our path will be resolved to the hexsha which will be used accordingly
return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
- def _get_commit(self):
+ def _get_commit(self) -> 'Commit':
"""
:return:
Commit object we point to, works for detached and non-detached
@@ -216,7 +217,8 @@ class SymbolicReference(object):
# END handle type
return obj
- def set_commit(self, commit: Union[Commit, 'SymbolicReference', str], logmsg=None):
+ def set_commit(self, commit: Union[Commit, 'SymbolicReference', str],
+ logmsg: Union[str, None] = None) -> None:
"""As set_object, but restricts the type of object to be a Commit
:raise ValueError: If commit is not a Commit object or doesn't point to
@@ -243,7 +245,8 @@ class SymbolicReference(object):
# we leave strings to the rev-parse method below
self.set_object(commit, logmsg)
- return self
+ # return self
+ return None
def set_object(self, object, logmsg=None): # @ReservedAssignment
"""Set the object we point to, possibly dereference our symbolic reference first.
@@ -275,7 +278,8 @@ class SymbolicReference(object):
commit = property(_get_commit, set_commit, doc="Query or set commits directly")
object = property(_get_object, set_object, doc="Return the object our ref currently refers to")
- def _get_reference(self):
+ def _get_reference(self
+ ) -> Union['HEAD', 'Head', 'RemoteReference', 'TagReference', 'Reference', 'SymbolicReference']:
""":return: Reference Object we point to
:raise TypeError: If this symbolic reference is detached, hence it doesn't point
to a reference, but to a commit"""