Skip to content

Commit 4f13b4e

Browse files
committed
fix base,ours,theirs typing
1 parent c27d2b0 commit 4f13b4e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

‎git/index/fun.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ def aggressive_tree_merge(odb, tree_shas: Sequence[bytes]) -> List[BaseIndexEntr
386386
# END handle ours
387387
else:
388388
# all three can't be None
389-
if ours is None and theirs is not None:
389+
if ours is None:
390390
# added in their branch
391-
out.append(_tree_entry_to_baseindexentry(theirs, 0))
392-
elif theirs is None and ours is not None:
391+
out.append(_tree_entry_to_baseindexentry(theirs, 0)) # type: ignore
392+
elif theirs is None: # ours is not None, theirs is None
393393
# added in our branch
394394
out.append(_tree_entry_to_baseindexentry(ours, 0))
395-
elif ours is not None and theirs is not None:
395+
else:
396396
# both have it, except for the base, see whether it changed
397397
if ours[0] != theirs[0] or ours[1] != theirs[1]:
398398
out.append(_tree_entry_to_baseindexentry(ours, 2))

‎git/objects/fun.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ def tree_entries_from_data(data: bytes) -> List[EntryTup]:
102102
return out
103103

104104

105-
def _find_by_name(tree_data: Sequence[EntryTupOrNone], name: str, is_dir: bool, start_at: int
105+
def _find_by_name(tree_data: List[EntryTupOrNone], name: str, is_dir: bool, start_at: int
106106
) -> EntryTupOrNone:
107107
"""return data entry matching the given name and tree mode
108108
or None.
109109
Before the item is returned, the respective data item is set
110110
None in the tree_data list to mark it done"""
111-
tree_data_list: List[EntryTupOrNone] = list(tree_data)
111+
tree_data_list: List[EntryTupOrNone] = tree_data
112112
try:
113113
item = tree_data_list[start_at]
114114
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
160160
set it '' for the first iteration
161161
:note: The ordering of the returned items will be partially lost"""
162162
trees_data: List[List[EntryTupOrNone]] = []
163+
163164
nt = len(tree_shas)
164165
for tree_sha in tree_shas:
165166
if tree_sha is None:
@@ -193,8 +194,7 @@ def traverse_trees_recursive(odb: 'GitCmdObjectDB', tree_shas: Sequence[Union[by
193194
# ti+nt, not ti+1+nt
194195
for tio in range(ti + 1, ti + nt):
195196
tio = tio % nt
196-
td = trees_data[tio]
197-
entries[tio] = _find_by_name(td, name, is_dir, ii)
197+
entries[tio] = _find_by_name(trees_data[tio], name, is_dir, ii)
198198

199199
# END for each other item data
200200
# if we are a directory, enter recursion

‎git/objects/tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
def git_cmp(t1: TreeCacheTup, t2: TreeCacheTup) -> int:
4646
a, b = t1[2], t2[2]
47-
assert isinstance(a, str) and isinstance(b, str) # Need as mypy 9.0 cannot unpack TypeVar properly
47+
# assert isinstance(a, str) and isinstance(b, str)
4848
len_a, len_b = len(a), len(b)
4949
min_len = min(len_a, len_b)
5050
min_cmp = cmp(a[:min_len], b[:min_len])

0 commit comments

Comments
 (0)