@@ -102,13 +102,13 @@ def tree_entries_from_data(data: bytes) -> List[EntryTup]:
102
102
return out
103
103
104
104
105
- def _find_by_name (tree_data : Sequence [Union [ EntryTup , None ] ], name : str , is_dir : bool , start_at : int
106
- ) -> Union [ EntryTup , None ] :
105
+ def _find_by_name (tree_data : Sequence [EntryTupOrNone ], name : str , is_dir : bool , start_at : int
106
+ ) -> EntryTupOrNone :
107
107
"""return data entry matching the given name and tree mode
108
108
or None.
109
109
Before the item is returned, the respective data item is set
110
110
None in the tree_data list to mark it done"""
111
- tree_data_list : List [Union [ EntryTup , None ] ] = list (tree_data )
111
+ tree_data_list : List [EntryTupOrNone ] = list (tree_data )
112
112
try :
113
113
item = tree_data_list [start_at ]
114
114
if item and item [2 ] == name and S_ISDIR (item [1 ]) == is_dir :
@@ -136,15 +136,15 @@ def _to_full_path(item: EntryTup, path_prefix: str) -> EntryTup:
136
136
...
137
137
138
138
139
- def _to_full_path (item : Union [ EntryTup , None ], path_prefix : str ) -> Union [ EntryTup , None ] :
139
+ def _to_full_path (item : EntryTupOrNone , path_prefix : str ) -> EntryTupOrNone :
140
140
"""Rebuild entry with given path prefix"""
141
141
if not item :
142
142
return item
143
143
return (item [0 ], item [1 ], path_prefix + item [2 ])
144
144
145
145
146
146
def traverse_trees_recursive (odb : 'GitCmdObjectDB' , tree_shas : Sequence [Union [bytes , None ]],
147
- path_prefix : str ) -> List [Union [ EntryTup , None ] ]:
147
+ path_prefix : str ) -> List [EntryTupOrNone ]:
148
148
"""
149
149
:return: list with entries according to the given binary tree-shas.
150
150
The result is encoded in a list
@@ -159,11 +159,11 @@ def traverse_trees_recursive(odb: 'GitCmdObjectDB', tree_shas: Sequence[Union[by
159
159
:param path_prefix: a prefix to be added to the returned paths on this level,
160
160
set it '' for the first iteration
161
161
:note: The ordering of the returned items will be partially lost"""
162
- trees_data : List [List [Union [ EntryTup , None ] ]] = []
162
+ trees_data : List [List [EntryTupOrNone ]] = []
163
163
nt = len (tree_shas )
164
164
for tree_sha in tree_shas :
165
165
if tree_sha is None :
166
- data : List [Union [ EntryTup , None ] ] = []
166
+ data : List [EntryTupOrNone ] = []
167
167
else :
168
168
data = list (tree_entries_from_data (odb .stream (tree_sha ).read ())) # make new list for typing as invariant
169
169
# END handle muted trees
@@ -181,7 +181,7 @@ def traverse_trees_recursive(odb: 'GitCmdObjectDB', tree_shas: Sequence[Union[by
181
181
if not item :
182
182
continue
183
183
# END skip already done items
184
- entries : List [Union [ EntryTup , None ] ]
184
+ entries : List [EntryTupOrNone ]
185
185
entries = [None for _ in range (nt )]
186
186
entries [ti ] = item
187
187
_sha , mode , name = item
@@ -196,8 +196,6 @@ def traverse_trees_recursive(odb: 'GitCmdObjectDB', tree_shas: Sequence[Union[by
196
196
entries [tio ] = _find_by_name (td , name , is_dir , ii )
197
197
198
198
# END for each other item data
199
- #Revealed type is "builtins.list[Union[Tuple[builtins.bytes, builtins.int, builtins.str], None]]"## #
200
- #Revealed type is "builtins.list[Union[Tuple[builtins.bytes, builtins.int, builtins.str], None]]"
201
199
# if we are a directory, enter recursion
202
200
if is_dir :
203
201
out .extend (traverse_trees_recursive (
0 commit comments