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

Commit2a350b5

Browse files
committed
Add final final types to symbolic.py
1 parent3c2454d commit2a350b5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

‎git/refs/symbolic.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
__all__= ["SymbolicReference"]
4141

4242

43-
def_git_dir(repo:'Repo',path:PathLike)->PathLike:
43+
def_git_dir(repo:'Repo',path:Union[PathLike,None])->PathLike:
4444
""" Find the git dir that's appropriate for the path"""
4545
name=f"{path}"
4646
ifnamein ['HEAD','ORIG_HEAD','FETCH_HEAD','index','logs']:
@@ -140,26 +140,28 @@ def _iter_packed_refs(cls, repo: 'Repo') -> Iterator[Tuple[str, str]]:
140140
# alright.
141141

142142
@classmethod
143-
defdereference_recursive(cls,repo:'Repo',ref_path:PathLike)->str:
143+
defdereference_recursive(cls,repo:'Repo',ref_path:Union[PathLike,None])->str:
144144
"""
145145
:return: hexsha stored in the reference at the given ref_path, recursively dereferencing all
146146
intermediate references as required
147147
:param repo: the repository containing the reference at ref_path"""
148+
148149
whileTrue:
149-
hexsha,ref_path=cls._get_ref_info(repo,ref_path)# type: ignore
150+
hexsha,ref_path=cls._get_ref_info(repo,ref_path)
150151
ifhexshaisnotNone:
151152
returnhexsha
152153
# END recursive dereferencing
153154

154155
@classmethod
155-
def_get_ref_info_helper(cls,repo:'Repo',ref_path:PathLike)->Union[Tuple[str,None],Tuple[None,str]]:
156+
def_get_ref_info_helper(cls,repo:'Repo',ref_path:Union[PathLike,None]
157+
)->Union[Tuple[str,None],Tuple[None,str]]:
156158
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
157159
rela_path points to, or None. target_ref_path is the reference we
158160
point to, or None"""
159161
tokens:Union[None,List[str],Tuple[str,str]]=None
160162
repodir=_git_dir(repo,ref_path)
161163
try:
162-
withopen(os.path.join(repodir,ref_path),'rt',encoding='UTF-8')asfp:
164+
withopen(os.path.join(repodir,str(ref_path)),'rt',encoding='UTF-8')asfp:
163165
value=fp.read().rstrip()
164166
# Don't only split on spaces, but on whitespace, which allows to parse lines like
165167
# 60b64ef992065e2600bfef6187a97f92398a9144 branch 'master' of git-server:/path/to/repo
@@ -191,7 +193,7 @@ def _get_ref_info_helper(cls, repo: 'Repo', ref_path: PathLike) -> Union[Tuple[s
191193
raiseValueError("Failed to parse reference information from %r"%ref_path)
192194

193195
@classmethod
194-
def_get_ref_info(cls,repo:'Repo',ref_path:PathLike)->Union[Tuple[str,None],Tuple[None,str]]:
196+
def_get_ref_info(cls,repo:'Repo',ref_path:Union[PathLike,None])->Union[Tuple[str,None],Tuple[None,str]]:
195197
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
196198
rela_path points to, or None. target_ref_path is the reference we
197199
point to, or None"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp