summaryrefslogtreecommitdiff
path: root/git/refs
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-08-02 17:56:06 +0100
committerYobmod <yobmod@gmail.com>2021-08-02 17:56:06 +0100
commit481f672baab666d6e2f81e9288a5f3c42c884a8e (patch)
treec88f064fcdfa463c96ebdd0e0d694294b1cfe393 /git/refs
parent6470ad4a413fb7fbd9f2d3b9da1720c13ffc92bb (diff)
downloadgitpython-481f672baab666d6e2f81e9288a5f3c42c884a8e.tar.gz
Add __future__.annotations to repo/base.py
Diffstat (limited to 'git/refs')
-rw-r--r--git/refs/symbolic.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py
index 1c56c043..238be839 100644
--- a/git/refs/symbolic.py
+++ b/git/refs/symbolic.py
@@ -72,12 +72,13 @@ class SymbolicReference(object):
def __repr__(self) -> str:
return '<git.%s "%s">' % (self.__class__.__name__, self.path)
- def __eq__(self, other: Any) -> bool:
+ def __eq__(self, other: object) -> bool:
if hasattr(other, 'path'):
+ other = cast(SymbolicReference, other)
return self.path == other.path
return False
- def __ne__(self, other: Any) -> bool:
+ def __ne__(self, other: object) -> bool:
return not (self == other)
def __hash__(self) -> int:
@@ -364,8 +365,9 @@ class SymbolicReference(object):
return self
# aliased reference
+ reference: Union['Head', 'TagReference', 'RemoteReference', 'Reference']
reference = property(_get_reference, set_reference, doc="Returns the Reference we point to") # type: ignore
- ref: Union['Head', 'TagReference', 'RemoteReference', 'Reference'] = reference # type: ignore
+ ref = reference
def is_valid(self) -> bool:
"""
@@ -699,7 +701,9 @@ class SymbolicReference(object):
instance = ref_type(repo, path)
if instance.__class__ == SymbolicReference and instance.is_detached:
raise ValueError("SymbolRef was detached, we drop it")
- return instance
+ else:
+ assert isinstance(instance, Reference), "instance should be Reference or subtype"
+ return instance
except ValueError:
pass
# END exception handling