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

Commit265d40b

Browse files
committed
Add type to symbolicreference.rename()
1 parent34e9850 commit265d40b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

‎git/refs/symbolic.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
ifTYPE_CHECKING:
2828
fromgit.repoimportRepo
29+
fromgit.refsimportHead,TagReference,Reference
2930

3031
T_References=TypeVar('T_References',bound='SymbolicReference')
3132

@@ -59,10 +60,10 @@ class SymbolicReference(object):
5960

6061
def__init__(self,repo:'Repo',path:PathLike,check_path:bool=False):
6162
self.repo=repo
62-
self.path=str(path)
63+
self.path=path
6364

6465
def__str__(self)->str:
65-
returnself.path
66+
returnstr(self.path)
6667

6768
def__repr__(self):
6869
return'<git.%s "%s">'% (self.__class__.__name__,self.path)
@@ -84,7 +85,7 @@ def name(self) -> str:
8485
:return:
8586
In case of symbolic references, the shortest assumable name
8687
is the path itself."""
87-
returnself.path
88+
returnstr(self.path)
8889

8990
@property
9091
defabspath(self)->PathLike:
@@ -557,7 +558,7 @@ def create(cls, repo: 'Repo', path: PathLike, reference: Union[Commit_ish, str]
557558
:note: This does not alter the current HEAD, index or Working Tree"""
558559
returncls._create(repo,path,cls._resolve_ref_on_create,reference,force,logmsg)
559560

560-
defrename(self,new_path,force=False):
561+
defrename(self,new_path:PathLike,force:bool=False)->'SymbolicReference':
561562
"""Rename self to a new path
562563
563564
:param new_path:
@@ -577,7 +578,7 @@ def rename(self, new_path, force=False):
577578

578579
new_abs_path=os.path.join(_git_dir(self.repo,new_path),new_path)
579580
cur_abs_path=os.path.join(_git_dir(self.repo,self.path),self.path)
580-
ifos.path.path.isfile(new_abs_path):
581+
ifos.path.isfile(new_abs_path):
581582
ifnotforce:
582583
# if they point to the same file, its not an error
583584
withopen(new_abs_path,'rb')asfd1:
@@ -663,7 +664,7 @@ def iter_items(cls: Type[T_References], repo: 'Repo', common_path: Union[PathLik
663664
return (rforrincls._iter_items(repo,common_path)ifr.__class__==SymbolicReferenceornotr.is_detached)
664665

665666
@classmethod
666-
deffrom_path(cls,repo,path):
667+
deffrom_path(cls,repo:'Repo',path:PathLike)->Union['Head','TagReference','Reference']:
667668
"""
668669
:param path: full .git-directory-relative path name to the Reference to instantiate
669670
:note: use to_full_path() if you only have a partial path of a known Reference Type

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp