2525
2626if TYPE_CHECKING :
2727from git .repo import Repo
28- from git .refs import Reference ,Head ,TagReference ,RemoteReference
29- from git .config import GitConfigParser
30- from git .objects .commit import Actor
28+ from git .refs import Reference ,Head ,TagReference ,RemoteReference # NOQA
29+ from git .config import GitConfigParser # NOQA
30+ from git .objects .commit import Actor # NOQA
3131
3232T_References = TypeVar ('T_References' ,bound = 'SymbolicReference' )
3333
3737__all__ = ["SymbolicReference" ]
3838
3939
40- def _git_dir (repo ,path ) :
40+ def _git_dir (repo : 'Repo' ,path : PathLike ) -> PathLike :
4141""" Find the git dir that's appropriate for the path"""
42- name = "%s" % ( path ,)
42+ name = f" { path } "
4343if name in ['HEAD' ,'ORIG_HEAD' ,'FETCH_HEAD' ,'index' ,'logs' ]:
4444return repo .git_dir
4545return repo .common_dir
@@ -59,34 +59,35 @@ class SymbolicReference(object):
5959_remote_common_path_default = "refs/remotes"
6060_id_attribute_ = "name"
6161
62- def __init__ (self ,repo :'Repo' ,path :PathLike ,check_path :bool = False ):
62+ def __init__ (self ,repo :'Repo' ,path :PathLike ,check_path :bool = False )-> None :
6363self .repo = repo
6464self .path = str (path )
65+ self .ref = self ._get_reference ()
6566
6667def __str__ (self )-> str :
6768return self .path
6869
69- def __repr__ (self ):
70+ def __repr__ (self )-> str :
7071return '<git.%s "%s">' % (self .__class__ .__name__ ,self .path )
7172
72- def __eq__ (self ,other ):
73+ def __eq__ (self ,other )-> bool :
7374if hasattr (other ,'path' ):
7475return self .path == other .path
7576return False
7677
77- def __ne__ (self ,other ):
78+ def __ne__ (self ,other )-> bool :
7879return not (self == other )
7980
8081def __hash__ (self ):
8182return hash (self .path )
8283
8384@property
84- def name (self ):
85+ def name (self )-> str :
8586"""
8687 :return:
8788 In case of symbolic references, the shortest assumable name
8889 is the path itself."""
89- return self .path
90+ return str ( self .path )
9091
9192@property
9293def abspath (self ):