Skip to content

Commit 8eedc9d

Browse files
committed
Add type to symbolicreference.get_()
1 parent 24c1242 commit 8eedc9d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Diff for: git/refs/symbolic.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
__all__ = ["SymbolicReference"]
3737

3838

39-
def _git_dir(repo: 'Repo', path: Union[PathLike, None]) -> PathLike:
39+
def _git_dir(repo: 'Repo', path: PathLike) -> PathLike:
4040
""" Find the git dir that's appropriate for the path"""
4141
name = f"{path}"
4242
if name in ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'index', 'logs']:
@@ -136,27 +136,26 @@ def _iter_packed_refs(cls, repo: 'Repo') -> Iterator[Tuple[str, str]]:
136136
# alright.
137137

138138
@classmethod
139-
def dereference_recursive(cls, repo: 'Repo', ref_path: Union[None, PathLike]) -> str:
139+
def dereference_recursive(cls, repo: 'Repo', ref_path: PathLike) -> str:
140140
"""
141141
:return: hexsha stored in the reference at the given ref_path, recursively dereferencing all
142142
intermediate references as required
143143
:param repo: the repository containing the reference at ref_path"""
144-
while True: # loop that overwrites ref_path each loop
144+
while True:
145145
hexsha, ref_path = cls._get_ref_info(repo, ref_path)
146146
if hexsha is not None:
147147
return hexsha
148148
# END recursive dereferencing
149149

150150
@classmethod
151-
def _get_ref_info_helper(cls, repo: 'Repo', ref_path: Union[PathLike, None]
152-
) -> Union[Tuple[str, None], Tuple[None, str]]:
151+
def _get_ref_info_helper(cls, repo: 'Repo', ref_path: PathLike):
153152
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
154153
rela_path points to, or None. target_ref_path is the reference we
155154
point to, or None"""
156155
tokens: Union[None, List[str], Tuple[str, str]] = None
157156
repodir = _git_dir(repo, ref_path)
158157
try:
159-
with open(os.path.join(repodir, cast(str, ref_path)), 'rt', encoding='UTF-8') as fp:
158+
with open(os.path.join(repodir, ref_path), 'rt', encoding='UTF-8') as fp:
160159
value = fp.read().rstrip()
161160
# Don't only split on spaces, but on whitespace, which allows to parse lines like
162161
# 60b64ef992065e2600bfef6187a97f92398a9144 branch 'master' of git-server:/path/to/repo
@@ -188,7 +187,7 @@ def _get_ref_info_helper(cls, repo: 'Repo', ref_path: Union[PathLike, None]
188187
raise ValueError("Failed to parse reference information from %r" % ref_path)
189188

190189
@classmethod
191-
def _get_ref_info(cls, repo: 'Repo', ref_path: Union[PathLike, None]) -> Union[Tuple[str, None], Tuple[None, str]]:
190+
def _get_ref_info(cls, repo, ref_path):
192191
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
193192
rela_path points to, or None. target_ref_path is the reference we
194193
point to, or None"""

0 commit comments

Comments
 (0)