Skip to content

Commit e8442ee

Browse files
committed
Add type to symbolicreference.set_reference()
1 parent 7f401fc commit e8442ee

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

git/refs/symbolic.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ def _get_reference(self):
289289
raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha))
290290
return self.from_path(self.repo, target_ref_path)
291291

292-
def set_reference(self, ref, logmsg=None):
292+
def set_reference(self, ref: Union[Commit_ish, 'SymbolicReference', str],
293+
logmsg: Union[str, None] = None) -> Union[Commit_ish, 'SymbolicReference']:
293294
"""Set ourselves to the given ref. It will stay a symbol if the ref is a Reference.
294295
Otherwise an Object, given as Object instance or refspec, is assumed and if valid,
295296
will be set which effectively detaches the refererence if it was a purely
@@ -330,7 +331,7 @@ def set_reference(self, ref, logmsg=None):
330331
raise TypeError("Require commit, got %r" % obj)
331332
# END verify type
332333

333-
oldbinsha = None
334+
oldbinsha: bytes = b''
334335
if logmsg is not None:
335336
try:
336337
oldbinsha = self.commit.binsha
@@ -359,8 +360,8 @@ def set_reference(self, ref, logmsg=None):
359360
return self
360361

361362
# aliased reference
362-
reference = property(_get_reference, set_reference, doc="Returns the Reference we point to")
363-
ref: Union['Reference'] = reference # type: ignore
363+
reference = property(_get_reference, set_reference, doc="Returns the Reference we point to") # type: ignore
364+
ref: Union['Reference'] = reference # type: ignore
364365

365366
def is_valid(self) -> bool:
366367
"""

0 commit comments

Comments
 (0)