Skip to content

More types for symbolic.py #1307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jul 31, 2021
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3347c00
change ordereddict guard, add type: ignore
Yobmod Jul 28, 2021
77a7769
Merge branch 'main' of https://github.com/Yobmod/GitPython
Yobmod Jul 28, 2021
28fdd30
Fix SymbolicReference reference typing
Yobmod Jul 28, 2021
3abc837
Add another type ignore for Ordereddict
Yobmod Jul 28, 2021
6791424
Rmv py 3.10 check for typing.Ordereddict - its deprecated then, but w…
Yobmod Jul 28, 2021
c464e33
Fix some SymbolicReference types
Yobmod Jul 28, 2021
7cf30c1
Fix forwardref
Yobmod Jul 28, 2021
5b880c0
Fix more missing types in Symbolic.py
Yobmod Jul 28, 2021
07d71e5
Fix more missing types in Symbolic.py
Yobmod Jul 28, 2021
b8b07b9
Fix more missing types in Symbolic.py.
Yobmod Jul 28, 2021
390efbf
Fix more missing types in Symbolic.py, cos GuthubActions pytest stuck
Yobmod Jul 28, 2021
070f5c0
Rmv test file
Yobmod Jul 28, 2021
adc00dd
Fix more missing types in Symbolic.py, cos GuthubActions pytest stuck
Yobmod Jul 28, 2021
28251c3
Try downgrading pip
Yobmod Jul 28, 2021
dbb689b
its not pip...
Yobmod Jul 28, 2021
cf29514
try https://github.com/actions/virtual-environments/issues/709 workar…
Yobmod Jul 28, 2021
f1e6e8d
Merge branch 'main' of https://github.com/Yobmod/GitPython
Yobmod Jul 31, 2021
15d1c01
Add type to symbolicreference.name()
Yobmod Jul 31, 2021
34e9850
Add type to symbolicreference.iter_items()
Yobmod Jul 31, 2021
265d40b
Add type to symbolicreference.rename()
Yobmod Jul 31, 2021
bdd6a43
Add type to symbolicreference.__repr__()
Yobmod Jul 31, 2021
1f92267
Add type to symbolicreference._get_ref_info()
Yobmod Jul 31, 2021
ad4517f
Add type to symbolicreference._get_packed_refs_path()
Yobmod Jul 31, 2021
6b0faba
Add type to symbolicreference.dereference_recursive()
Yobmod Jul 31, 2021
7e972b9
Add type to symbolicreference.dereference_recursive()
Yobmod Jul 31, 2021
24c1242
Add type to symbolicreference()
Yobmod Jul 31, 2021
8eedc9d
Add type to symbolicreference.get_()
Yobmod Jul 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add type to symbolicreference._get_packed_refs_path()
  • Loading branch information
Yobmod committed Jul 31, 2021
commit ad4517ff7c6bb629097a1adae204c27a7af4ba4b
22 changes: 11 additions & 11 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,23 @@ def _iter_packed_refs(cls, repo: 'Repo') -> Iterator[Tuple[str, str]]:
# alright.

@classmethod
def dereference_recursive(cls, repo: 'Repo', ref_path: PathLike) -> str:
def dereference_recursive(cls, repo, ref_path):
"""
:return: hexsha stored in the reference at the given ref_path, recursively dereferencing all
intermediate references as required
:param repo: the repository containing the reference at ref_path"""
while True:
hexsha, _ref_path = cls._get_ref_info(repo, ref_path)
hexsha, ref_path = cls._get_ref_info(repo, ref_path)
if hexsha is not None:
return hexsha
# END recursive dereferencing

@classmethod
def _get_ref_info_helper(cls, repo: 'Repo', ref_path: PathLike) -> Union[Tuple[str, None], Tuple[None, str]]:
def _get_ref_info_helper(cls, repo, ref_path):
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
rela_path points to, or None. target_ref_path is the reference we
point to, or None"""
tokens: Union[Tuple[str, str], List[str], None] = None
tokens = None
repodir = _git_dir(repo, ref_path)
try:
with open(os.path.join(repodir, ref_path), 'rt', encoding='UTF-8') as fp:
Expand All @@ -169,7 +169,7 @@ def _get_ref_info_helper(cls, repo: 'Repo', ref_path: PathLike) -> Union[Tuple[s
if path != ref_path:
continue
# sha will be used
tokens = (sha, path)
tokens = sha, path
break
# END for each packed ref
# END handle packed refs
Expand All @@ -186,8 +186,8 @@ def _get_ref_info_helper(cls, repo: 'Repo', ref_path: PathLike) -> Union[Tuple[s

raise ValueError("Failed to parse reference information from %r" % ref_path)

@ classmethod
def _get_ref_info(cls, repo: 'Repo', ref_path: PathLike) -> Union[Tuple[str, None], Tuple[None, str]]:
@classmethod
def _get_ref_info(cls, repo, ref_path):
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
rela_path points to, or None. target_ref_path is the reference we
point to, or None"""
Expand Down Expand Up @@ -370,7 +370,7 @@ def is_valid(self):
else:
return True

@ property
@property
def is_detached(self):
"""
:return:
Expand Down Expand Up @@ -420,7 +420,7 @@ def log_entry(self, index):
In that case, it will be faster than the ``log()`` method"""
return RefLog.entry_at(RefLog.path(self), index)

@ classmethod
@classmethod
def to_full_path(cls, path) -> PathLike:
"""
:return: string with a full repository-relative path which can be used to initialize
Expand All @@ -434,7 +434,7 @@ def to_full_path(cls, path) -> PathLike:
full_ref_path = '%s/%s' % (cls._common_path_default, path)
return full_ref_path

@ classmethod
@classmethod
def delete(cls, repo, path):
"""Delete the reference at the given path

Expand Down Expand Up @@ -492,7 +492,7 @@ def delete(cls, repo, path):
os.remove(reflog_path)
# END remove reflog

@ classmethod
@classmethod
def _create(cls, repo, path, resolve, reference, force, logmsg=None):
"""internal method used to create a new symbolic reference.
If resolve is False, the reference will be taken as is, creating
Expand Down