summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-07-08 23:49:01 +0100
committerYobmod <yobmod@gmail.com>2021-07-08 23:49:01 +0100
commit4f13b4e23526616f307370dc9a869b067e90b276 (patch)
treee389bba12640d5f1281a64167b6fc7c6ed9a198e /git
parentc27d2b078b515a8321b3f7f7abdcea363d8049df (diff)
downloadgitpython-4f13b4e23526616f307370dc9a869b067e90b276.tar.gz
fix base,ours,theirs typing
Diffstat (limited to 'git')
-rw-r--r--git/index/fun.py8
-rw-r--r--git/objects/fun.py8
-rw-r--r--git/objects/tree.py2
3 files changed, 9 insertions, 9 deletions
diff --git a/git/index/fun.py b/git/index/fun.py
index cd71237d..774738db 100644
--- a/git/index/fun.py
+++ b/git/index/fun.py
@@ -386,13 +386,13 @@ def aggressive_tree_merge(odb, tree_shas: Sequence[bytes]) -> List[BaseIndexEntr
# END handle ours
else:
# all three can't be None
- if ours is None and theirs is not None:
+ if ours is None:
# added in their branch
- out.append(_tree_entry_to_baseindexentry(theirs, 0))
- elif theirs is None and ours is not None:
+ out.append(_tree_entry_to_baseindexentry(theirs, 0)) # type: ignore
+ elif theirs is None: # ours is not None, theirs is None
# added in our branch
out.append(_tree_entry_to_baseindexentry(ours, 0))
- elif ours is not None and theirs is not None:
+ else:
# both have it, except for the base, see whether it changed
if ours[0] != theirs[0] or ours[1] != theirs[1]:
out.append(_tree_entry_to_baseindexentry(ours, 2))
diff --git a/git/objects/fun.py b/git/objects/fun.py
index 42954fc2..57cefcf2 100644
--- a/git/objects/fun.py
+++ b/git/objects/fun.py
@@ -102,13 +102,13 @@ def tree_entries_from_data(data: bytes) -> List[EntryTup]:
return out
-def _find_by_name(tree_data: Sequence[EntryTupOrNone], name: str, is_dir: bool, start_at: int
+def _find_by_name(tree_data: List[EntryTupOrNone], name: str, is_dir: bool, start_at: int
) -> EntryTupOrNone:
"""return data entry matching the given name and tree mode
or None.
Before the item is returned, the respective data item is set
None in the tree_data list to mark it done"""
- tree_data_list: List[EntryTupOrNone] = list(tree_data)
+ tree_data_list: List[EntryTupOrNone] = tree_data
try:
item = tree_data_list[start_at]
if item and item[2] == name and S_ISDIR(item[1]) == is_dir:
@@ -160,6 +160,7 @@ def traverse_trees_recursive(odb: 'GitCmdObjectDB', tree_shas: Sequence[Union[by
set it '' for the first iteration
:note: The ordering of the returned items will be partially lost"""
trees_data: List[List[EntryTupOrNone]] = []
+
nt = len(tree_shas)
for tree_sha in tree_shas:
if tree_sha is None:
@@ -193,8 +194,7 @@ def traverse_trees_recursive(odb: 'GitCmdObjectDB', tree_shas: Sequence[Union[by
# ti+nt, not ti+1+nt
for tio in range(ti + 1, ti + nt):
tio = tio % nt
- td = trees_data[tio]
- entries[tio] = _find_by_name(td, name, is_dir, ii)
+ entries[tio] = _find_by_name(trees_data[tio], name, is_dir, ii)
# END for each other item data
# if we are a directory, enter recursion
diff --git a/git/objects/tree.py b/git/objects/tree.py
index 528cf5ca..d3681e23 100644
--- a/git/objects/tree.py
+++ b/git/objects/tree.py
@@ -44,7 +44,7 @@ __all__ = ("TreeModifier", "Tree")
def git_cmp(t1: TreeCacheTup, t2: TreeCacheTup) -> int:
a, b = t1[2], t2[2]
- assert isinstance(a, str) and isinstance(b, str) # Need as mypy 9.0 cannot unpack TypeVar properly
+ # assert isinstance(a, str) and isinstance(b, str)
len_a, len_b = len(a), len(b)
min_len = min(len_a, len_b)
min_cmp = cmp(a[:min_len], b[:min_len])