@@ -285,7 +285,7 @@ def set_object(self, object: Union[Commit_ish, 'SymbolicReference', str], logmsg
285
285
commit = property (_get_commit , set_commit , doc = "Query or set commits directly" ) # type: ignore
286
286
object = property (_get_object , set_object , doc = "Return the object our ref currently refers to" ) # type: ignore
287
287
288
- def _get_reference (self ) -> 'Reference ' :
288
+ def _get_reference (self ) -> 'SymbolicReference ' :
289
289
""":return: Reference Object we point to
290
290
:raise TypeError: If this symbolic reference is detached, hence it doesn't point
291
291
to a reference, but to a commit"""
@@ -683,7 +683,7 @@ def iter_items(cls: Type[T_References], repo: 'Repo', common_path: Union[PathLik
683
683
return (r for r in cls ._iter_items (repo , common_path ) if r .__class__ == SymbolicReference or not r .is_detached )
684
684
685
685
@classmethod
686
- def from_path (cls , repo : 'Repo' , path : PathLike ) -> Union [ 'Head' , 'TagReference' , 'Reference' ] :
686
+ def from_path (cls : Type [ T_References ] , repo : 'Repo' , path : PathLike ) -> T_References :
687
687
"""
688
688
:param path: full .git-directory-relative path name to the Reference to instantiate
689
689
:note: use to_full_path() if you only have a partial path of a known Reference Type
@@ -698,12 +698,13 @@ def from_path(cls, repo: 'Repo', path: PathLike) -> Union['Head', 'TagReference'
698
698
from . import HEAD , Head , RemoteReference , TagReference , Reference
699
699
for ref_type in (HEAD , Head , RemoteReference , TagReference , Reference , SymbolicReference ):
700
700
try :
701
+ instance : T_References
701
702
instance = ref_type (repo , path )
702
703
if instance .__class__ == SymbolicReference and instance .is_detached :
703
704
raise ValueError ("SymbolRef was detached, we drop it" )
704
705
else :
705
- assert isinstance (instance , Reference ), "instance should be Reference or subtype"
706
706
return instance
707
+
707
708
except ValueError :
708
709
pass
709
710
# END exception handling
0 commit comments