diff options
author | Yobmod <yobmod@gmail.com> | 2021-08-02 18:14:40 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-08-02 18:14:40 +0100 |
commit | 9de7310f1a2bfcb90ca5c119321037d5ea97b24e (patch) | |
tree | f3601d649df87b4b193e36317d11ad46f0a2610f /git/refs | |
parent | 481f672baab666d6e2f81e9288a5f3c42c884a8e (diff) | |
download | gitpython-9de7310f1a2bfcb90ca5c119321037d5ea97b24e.tar.gz |
Minor type fixes
Diffstat (limited to 'git/refs')
-rw-r--r-- | git/refs/symbolic.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py index 238be839..0c0fa404 100644 --- a/git/refs/symbolic.py +++ b/git/refs/symbolic.py @@ -285,7 +285,7 @@ class SymbolicReference(object): 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) -> 'Reference': + 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""" @@ -683,7 +683,7 @@ class SymbolicReference(object): return (r for r in cls._iter_items(repo, common_path) if r.__class__ == SymbolicReference or not r.is_detached) @classmethod - def from_path(cls, repo: 'Repo', path: PathLike) -> Union['Head', 'TagReference', 'Reference']: + def from_path(cls: Type[T_References], repo: 'Repo', path: PathLike) -> T_References: """ :param path: full .git-directory-relative path name to the Reference to instantiate :note: use to_full_path() if you only have a partial path of a known Reference Type @@ -698,12 +698,13 @@ class SymbolicReference(object): from . import HEAD, Head, RemoteReference, TagReference, Reference for ref_type in (HEAD, Head, RemoteReference, TagReference, Reference, SymbolicReference): try: + instance: T_References instance = ref_type(repo, path) if instance.__class__ == SymbolicReference and instance.is_detached: raise ValueError("SymbolRef was detached, we drop it") else: - assert isinstance(instance, Reference), "instance should be Reference or subtype" return instance + except ValueError: pass # END exception handling |