2525
2626if TYPE_CHECKING :
2727from git .repo import Repo
28- from git .refs import Reference
28+ from git .refs import Reference , Head , HEAD , TagReference , RemoteReference
2929
3030T_References = TypeVar ('T_References' ,bound = 'SymbolicReference' )
3131
@@ -141,13 +141,13 @@ def dereference_recursive(cls, repo: 'Repo', ref_path: PathLike) -> str:
141141 intermediate references as required
142142 :param repo: the repository containing the reference at ref_path"""
143143while True :
144- hexsha ,ref_path = cls ._get_ref_info (repo ,ref_path )
144+ hexsha ,_ref_path_out = cls ._get_ref_info (repo ,ref_path )
145145if hexsha is not None :
146146return hexsha
147147# END recursive dereferencing
148148
149149@classmethod
150- def _get_ref_info_helper (cls ,repo :'Repo' ,ref_path :PathLike ):
150+ def _get_ref_info_helper (cls ,repo :'Repo' ,ref_path :PathLike )-> Union [ Tuple [ str , None ], Tuple [ None , PathLike ]] :
151151"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
152152 rela_path points to, or None. target_ref_path is the reference we
153153 point to, or None"""
@@ -186,13 +186,14 @@ def _get_ref_info_helper(cls, repo: 'Repo', ref_path: PathLike):
186186raise ValueError ("Failed to parse reference information from %r" % ref_path )
187187
188188@classmethod
189- def _get_ref_info (cls ,repo :'Repo' ,ref_path :PathLike ):
189+ def _get_ref_info (cls ,repo :'Repo' ,ref_path :PathLike
190+ )-> Union [Tuple [str ,None ],Tuple [None ,PathLike ]]:
190191"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
191192 rela_path points to, or None. target_ref_path is the reference we
192193 point to, or None"""
193194return cls ._get_ref_info_helper (repo ,ref_path )
194195
195- def _get_object (self ):
196+ def _get_object (self )-> Commit_ish :
196197"""
197198 :return:
198199 The object our ref currently refers to. Refs can be cached, they will
@@ -201,7 +202,7 @@ def _get_object(self):
201202# Our path will be resolved to the hexsha which will be used accordingly
202203return Object .new_from_sha (self .repo ,hex_to_bin (self .dereference_recursive (self .repo ,self .path )))
203204
204- def _get_commit (self ):
205+ def _get_commit (self )-> 'Commit' :
205206"""
206207 :return:
207208 Commit object we point to, works for detached and non-detached
@@ -216,7 +217,8 @@ def _get_commit(self):
216217# END handle type
217218return obj
218219
219- def set_commit (self ,commit :Union [Commit ,'SymbolicReference' ,str ],logmsg = None ):
220+ def set_commit (self ,commit :Union [Commit ,'SymbolicReference' ,str ],
221+ logmsg :Union [str ,None ]= None )-> None :
220222"""As set_object, but restricts the type of object to be a Commit
221223
222224 :raise ValueError: If commit is not a Commit object or doesn't point to
@@ -243,7 +245,8 @@ def set_commit(self, commit: Union[Commit, 'SymbolicReference', str], logmsg=Non
243245# we leave strings to the rev-parse method below
244246self .set_object (commit ,logmsg )
245247
246- return self
248+ # return self
249+ return None
247250
248251def set_object (self ,object ,logmsg = None ):# @ReservedAssignment
249252"""Set the object we point to, possibly dereference our symbolic reference first.
@@ -275,7 +278,8 @@ def set_object(self, object, logmsg=None): # @ReservedAssignment
275278commit = property (_get_commit ,set_commit ,doc = "Query or set commits directly" )
276279object = property (_get_object ,set_object ,doc = "Return the object our ref currently refers to" )
277280
278- def _get_reference (self ):
281+ def _get_reference (self
282+ )-> Union ['HEAD' ,'Head' ,'RemoteReference' ,'TagReference' ,'Reference' ,'SymbolicReference' ]:
279283""":return: Reference Object we point to
280284 :raise TypeError: If this symbolic reference is detached, hence it doesn't point
281285 to a reference, but to a commit"""