From 481f672baab666d6e2f81e9288a5f3c42c884a8e Mon Sep 17 00:00:00 2001 From: Yobmod Date: Mon, 2 Aug 2021 17:56:06 +0100 Subject: Add __future__.annotations to repo/base.py --- git/refs/symbolic.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'git/refs') 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 '' % (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 -- cgit v1.2.1