Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4b9ca92

Browse files
committed
Add types to refs/remote.py
1 parent8dd3d0d commit4b9ca92

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

‎git/refs/remote.py‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,43 @@
22

33
fromgit.utilimportjoin_path
44

5-
importos.pathasosp
6-
75
from .headimportHead
86

97

108
__all__= ["RemoteReference"]
119

10+
# typing ------------------------------------------------------------------
11+
12+
fromtypingimportAny,NoReturn,Union,TYPE_CHECKING
13+
fromgit.typesimportPathLike
14+
15+
16+
ifTYPE_CHECKING:
17+
fromgit.repoimportRepo
18+
fromgitimportRemote
19+
20+
# ------------------------------------------------------------------------------
21+
1222

1323
classRemoteReference(Head):
1424

1525
"""Represents a reference pointing to a remote head."""
1626
_common_path_default=Head._remote_common_path_default
1727

1828
@classmethod
19-
defiter_items(cls,repo,common_path=None,remote=None):
29+
defiter_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_pathorcls._common_path_default
2234
ifremoteisnotNone:
2335
common_path=join_path(common_path,str(remote))
2436
# END handle remote constraint
37+
# super is Reference
2538
returnsuper(RemoteReference,cls).iter_items(repo,common_path)
2639

27-
@classmethod
28-
defdelete(cls,repo,*refs,**kwargs):
40+
@classmethod
41+
defdelete(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
forrefinrefs:
3952
try:
40-
os.remove(osp.join(repo.common_dir,ref.path))
53+
os.remove(os.path.join(repo.common_dir,ref.path))
4154
exceptOSError:
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
exceptOSError:
4659
pass
4760
# END for each ref
4861

49-
@classmethod
50-
defcreate(cls,*args,**kwargs):
62+
@classmethod
63+
defcreate(cls,*args:Any,**kwargs:Any)->NoReturn:
5164
"""Used to disable this method"""
5265
raiseTypeError("Cannot explicitly create remote references")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp