|
31 | 31 | from io import BytesIO
|
32 | 32 |
|
33 | 33 | TreeCacheTup = Tuple[bytes, int, str]
|
| 34 | + |
34 | 35 | TraversedTreeTup = Union[Tuple[Union['Tree', None], IndexObjUnion,
|
35 | 36 | Tuple['Submodule', 'Submodule']]]
|
36 | 37 |
|
| 38 | + |
| 39 | +def is_tree_cache(inp: Tuple[bytes, int, str]) -> TypeGuard[TreeCacheTup]: |
| 40 | + return isinstance(inp[0], bytes) and isinstance(inp[1], int) and isinstance([inp], str) |
| 41 | + |
37 | 42 | #--------------------------------------------------------
|
38 | 43 |
|
39 | 44 |
|
@@ -141,11 +146,8 @@ def add(self, sha: bytes, mode: int, name: str, force: bool = False) -> 'TreeMod
|
141 | 146 | sha = to_bin_sha(sha)
|
142 | 147 | index = self._index_by_name(name)
|
143 | 148 |
|
144 |
| - def is_tree_cache(inp: Tuple[bytes, int, str]) -> TypeGuard[TreeCacheTup]: |
145 |
| - return isinstance(inp[0], bytes) and isinstance(inp[1], int) and isinstance([inp], str) |
146 |
| - |
147 | 149 | item = (sha, mode, name)
|
148 |
| - assert is_tree_cache(item) |
| 150 | + # assert is_tree_cache(item) |
149 | 151 |
|
150 | 152 | if index == -1:
|
151 | 153 | self._cache.append(item)
|
@@ -223,12 +225,12 @@ def _set_cache_(self, attr: str) -> None:
|
223 | 225 | if attr == "_cache":
|
224 | 226 | # Set the data when we need it
|
225 | 227 | ostream = self.repo.odb.stream(self.binsha)
|
226 |
| - self._cache: List[Tuple[bytes, int, str]] = tree_entries_from_data(ostream.read()) |
| 228 | + self._cache: List[TreeCacheTup] = tree_entries_from_data(ostream.read()) |
227 | 229 | else:
|
228 | 230 | super(Tree, self)._set_cache_(attr)
|
229 | 231 | # END handle attribute
|
230 | 232 |
|
231 |
| - def _iter_convert_to_object(self, iterable: Iterable[Tuple[bytes, int, str]] |
| 233 | + def _iter_convert_to_object(self, iterable: Iterable[TreeCacheTup] |
232 | 234 | ) -> Iterator[IndexObjUnion]:
|
233 | 235 | """Iterable yields tuples of (binsha, mode, name), which will be converted
|
234 | 236 | to the respective object representation"""
|
|
0 commit comments