summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-07-31 17:25:46 +0100
committerYobmod <yobmod@gmail.com>2021-07-31 17:25:46 +0100
commitf2012e599e388580bf8823a23ff63a201e0bf4c4 (patch)
treef7c0242ca7b110da38435e28210b9ea4b19deb7f
parente8442eead72bfc2a547234d0289d0f90642167fd (diff)
downloadgitpython-f2012e599e388580bf8823a23ff63a201e0bf4c4.tar.gz
Add type to symbolicreference.set_object()
-rw-r--r--git/refs/reference.py4
-rw-r--r--git/refs/symbolic.py14
2 files changed, 10 insertions, 8 deletions
diff --git a/git/refs/reference.py b/git/refs/reference.py
index bc2c6e80..539691e7 100644
--- a/git/refs/reference.py
+++ b/git/refs/reference.py
@@ -63,8 +63,8 @@ class Reference(SymbolicReference, LazyMixin, IterableObj):
#{ Interface
# @ReservedAssignment
- def set_object(self, object: Union[Commit_ish, 'SymbolicReference'], logmsg: Union[str, None] = None
- ) -> 'SymbolicReference':
+ def set_object(self, object: Union[Commit_ish, 'SymbolicReference', str], logmsg: Union[str, None] = None
+ ) -> 'Reference':
"""Special version which checks if the head-log needs an update as well
:return: self"""
oldbinsha = None
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py
index 4713e0c4..0d2c9829 100644
--- a/git/refs/symbolic.py
+++ b/git/refs/symbolic.py
@@ -221,7 +221,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
+ ) -> 'SymbolicReference':
"""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
@@ -250,7 +251,8 @@ class SymbolicReference(object):
return self
- def set_object(self, object, logmsg=None): # @ReservedAssignment
+ def set_object(self, object: Union[Commit_ish, 'SymbolicReference', str], logmsg: Union[str, None] = None
+ ) -> 'SymbolicReference':
"""Set the object we point to, possibly dereference our symbolic reference first.
If the reference does not exist, it will be created
@@ -277,10 +279,10 @@ class SymbolicReference(object):
# set the commit on our reference
return self._get_reference().set_object(object, logmsg)
- 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")
+ commit = property(_get_commit, set_commit, doc="Query or set commits directly") # type: ignore
+ object = property(_get_object, set_object, doc="Return the object our ref currently refers to") # type: ignore
- def _get_reference(self):
+ def _get_reference(self) -> '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"""
@@ -290,7 +292,7 @@ class SymbolicReference(object):
return self.from_path(self.repo, target_ref_path)
def set_reference(self, ref: Union[Commit_ish, 'SymbolicReference', str],
- logmsg: Union[str, None] = None) -> Union[Commit_ish, 'SymbolicReference']:
+ logmsg: Union[str, None] = None) -> 'SymbolicReference':
"""Set ourselves to the given ref. It will stay a symbol if the ref is a Reference.
Otherwise an Object, given as Object instance or refspec, is assumed and if valid,
will be set which effectively detaches the refererence if it was a purely