@@ -285,7 +285,7 @@ def set_object(self, object: Union[Commit_ish, 'SymbolicReference', str], logmsg
285285commit = property (_get_commit ,set_commit ,doc = "Query or set commits directly" )# type: ignore
286286object = property (_get_object ,set_object ,doc = "Return the object our ref currently refers to" )# type: ignore
287287
288- def _get_reference (self )-> 'Reference ' :
288+ def _get_reference (self )-> 'SymbolicReference ' :
289289""":return: Reference Object we point to
290290 :raise TypeError: If this symbolic reference is detached, hence it doesn't point
291291 to a reference, but to a commit"""
@@ -683,7 +683,7 @@ def iter_items(cls: Type[T_References], repo: 'Repo', common_path: Union[PathLik
683683return (r for r in cls ._iter_items (repo ,common_path )if r .__class__ == SymbolicReference or not r .is_detached )
684684
685685@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 :
687687"""
688688 :param path: full .git-directory-relative path name to the Reference to instantiate
689689 :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'
698698from .import HEAD ,Head ,RemoteReference ,TagReference ,Reference
699699for ref_type in (HEAD ,Head ,RemoteReference ,TagReference ,Reference ,SymbolicReference ):
700700try :
701+ instance :T_References
701702instance = ref_type (repo ,path )
702703if instance .__class__ == SymbolicReference and instance .is_detached :
703704raise ValueError ("SymbolRef was detached, we drop it" )
704705else :
705- assert isinstance (instance ,Reference ),"instance should be Reference or subtype"
706706return instance
707+
707708except ValueError :
708709pass
709710# END exception handling