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

Commit1746b97

Browse files
authored
Merge pull request#1346 from rra/type-fixes
Fix typing issues with delete_head and Remote.add
2 parents2d15c5a +5f4b4db commit1746b97

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

‎git/refs/head.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class Head(Reference):
129129
k_config_remote_ref="merge"# branch to merge from remote
130130

131131
@classmethod
132-
defdelete(cls,repo:'Repo',*heads:'Head',force:bool=False,**kwargs:Any)->None:
132+
defdelete(cls,repo:'Repo',*heads:'Union[Head, str]',force:bool=False,**kwargs:Any)->None:
133133
"""Delete the given heads
134134
135135
:param force:

‎git/refs/remote.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ def iter_items(cls, repo: 'Repo', common_path: Union[PathLike, None] = None,
3737
# super is Reference
3838
returnsuper(RemoteReference,cls).iter_items(repo,common_path)
3939

40+
# The Head implementation of delete also accepts strs, but this
41+
# implementation does not. mypy doesn't have a way of representing
42+
# tightening the types of arguments in subclasses and recommends Any or
43+
# "type: ignore". (See https://github.com/python/typing/issues/241)
4044
@classmethod
41-
defdelete(cls,repo:'Repo',*refs:'RemoteReference',**kwargs:Any)->None:
45+
defdelete(cls,repo:'Repo',*refs:'RemoteReference',# type: ignore
46+
**kwargs:Any)->None:
4247
"""Delete the given remote references
4348
4449
:note:

‎git/remote.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,9 @@ def create(cls, repo: 'Repo', name: str, url: str, **kwargs: Any) -> 'Remote':
665665
returncls(repo,name)
666666

667667
# add is an alias
668-
add=create
668+
@classmethod
669+
defadd(cls,repo:'Repo',name:str,url:str,**kwargs:Any)->'Remote':
670+
returncls.create(repo,name,url,**kwargs)
669671

670672
@classmethod
671673
defremove(cls,repo:'Repo',name:str)->str:

‎git/repo/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def create_head(self, path: PathLike, commit: str = 'HEAD',
429429
:return: newly created Head Reference"""
430430
returnHead.create(self,path,commit,logmsg,force)
431431

432-
defdelete_head(self,*heads:'Head',**kwargs:Any)->None:
432+
defdelete_head(self,*heads:'Union[str,Head]',**kwargs:Any)->None:
433433
"""Delete the given heads
434434
435435
:param kwargs: Additional keyword arguments to be passed to git-branch"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp