22
33from git .util import join_path
44
5- import os .path as osp
6-
75from .head import Head
86
97
108__all__ = ["RemoteReference" ]
119
10+ # typing ------------------------------------------------------------------
11+
12+ from typing import Any , NoReturn , Union , TYPE_CHECKING
13+ from git .types import PathLike
14+
15+
16+ if TYPE_CHECKING :
17+ from git .repo import Repo
18+ from git import Remote
19+
20+ # ------------------------------------------------------------------------------
21+
1222
1323class RemoteReference (Head ):
1424
1525 """Represents a reference pointing to a remote head."""
1626 _common_path_default = Head ._remote_common_path_default
1727
1828 @classmethod
19- def iter_items (cls , repo , common_path = None , remote = None ):
29+ def iter_items (cls , repo : 'Repo' , common_path : Union [PathLike , None ] = None ,
30+ remote : Union ['Remote' , None ] = None , * args : Any , ** kwargs : Any
31+ ) -> 'RemoteReference' :
2032 """Iterate remote references, and if given, constrain them to the given remote"""
2133 common_path = common_path or cls ._common_path_default
2234 if remote is not None :
2335 common_path = join_path (common_path , str (remote ))
2436 # END handle remote constraint
37+ # super is Reference
2538 return super (RemoteReference , cls ).iter_items (repo , common_path )
2639
27- @classmethod
28- def delete (cls , repo , * refs , ** kwargs ) :
40+ @ classmethod
41+ def delete (cls , repo : 'Repo' , * refs : 'RemoteReference' , ** kwargs : Any ) -> None :
2942 """Delete the given remote references
3043
3144 :note:
@@ -37,16 +50,16 @@ def delete(cls, repo, *refs, **kwargs):
3750 # and delete remainders manually
3851 for ref in refs :
3952 try :
40- os .remove (osp .join (repo .common_dir , ref .path ))
53+ os .remove (os . path .join (repo .common_dir , ref .path ))
4154 except OSError :
4255 pass
4356 try :
44- os .remove (osp .join (repo .git_dir , ref .path ))
57+ os .remove (os . path .join (repo .git_dir , ref .path ))
4558 except OSError :
4659 pass
4760 # END for each ref
4861
49- @classmethod
50- def create (cls , * args , ** kwargs ) :
62+ @ classmethod
63+ def create (cls , * args : Any , ** kwargs : Any ) -> NoReturn :
5164 """Used to disable this method"""
5265 raise TypeError ("Cannot explicitly create remote references" )
0 commit comments