Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6a27ad

Browse files
committed
Use TreeCacheTup type alias throughout
1 parent2ea528e commite6a27ad

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

‎git/index/fun.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
ifTYPE_CHECKING:
5959
from .baseimportIndexFile
60+
fromobjects.treeimportTreeCacheTup
6061
# from git.objects.fun import EntryTupOrNone
6162

6263
# ------------------------------------------------------------------------------------
@@ -249,7 +250,7 @@ def read_cache(stream: IO[bytes]) -> Tuple[int, Dict[Tuple[PathLike, int], 'Inde
249250

250251

251252
defwrite_tree_from_cache(entries:List[IndexEntry],odb,sl:slice,si:int=0
252-
)->Tuple[bytes,List[Tuple[bytes,int,str]]]:
253+
)->Tuple[bytes,List[TreeCacheTup]]:
253254
"""Create a tree from the given sorted list of entries and put the respective
254255
trees into the given object database
255256
@@ -259,7 +260,7 @@ def write_tree_from_cache(entries: List[IndexEntry], odb, sl: slice, si: int = 0
259260
:param sl: slice indicating the range we should process on the entries list
260261
:return: tuple(binsha, list(tree_entry, ...)) a tuple of a sha and a list of
261262
tree entries being a tuple of hexsha, mode, name"""
262-
tree_items:List[Tuple[bytes,int,str]]= []
263+
tree_items:List[TreeCacheTup]= []
263264

264265
ci=sl.start
265266
end=sl.stop
@@ -305,7 +306,7 @@ def write_tree_from_cache(entries: List[IndexEntry], odb, sl: slice, si: int = 0
305306
return (istream.binsha,tree_items)
306307

307308

308-
def_tree_entry_to_baseindexentry(tree_entry:Tuple[bytes,int,str],stage:int)->BaseIndexEntry:
309+
def_tree_entry_to_baseindexentry(tree_entry:TreeCacheTup,stage:int)->BaseIndexEntry:
309310
returnBaseIndexEntry((tree_entry[1],tree_entry[0],stage<<CE_STAGESHIFT,tree_entry[2]))
310311

311312

‎git/objects/fun.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def traverse_trees_recursive(odb: 'GitCmdObjectDB', tree_shas: Sequence[Union[by
215215
returnout
216216

217217

218-
deftraverse_tree_recursive(odb:'GitCmdObjectDB',tree_sha:bytes,path_prefix:str)->List[Tuple[bytes,int,str]]:
218+
deftraverse_tree_recursive(odb:'GitCmdObjectDB',tree_sha:bytes,path_prefix:str)->List[EntryTup]:
219219
"""
220220
:return: list of entries of the tree pointed to by the binary tree_sha. An entry
221221
has the following format:

‎git/objects/tree.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@
3131
fromioimportBytesIO
3232

3333
TreeCacheTup=Tuple[bytes,int,str]
34+
3435
TraversedTreeTup=Union[Tuple[Union['Tree',None],IndexObjUnion,
3536
Tuple['Submodule','Submodule']]]
3637

38+
39+
defis_tree_cache(inp:Tuple[bytes,int,str])->TypeGuard[TreeCacheTup]:
40+
returnisinstance(inp[0],bytes)andisinstance(inp[1],int)andisinstance([inp],str)
41+
3742
#--------------------------------------------------------
3843

3944

@@ -141,11 +146,8 @@ def add(self, sha: bytes, mode: int, name: str, force: bool = False) -> 'TreeMod
141146
sha=to_bin_sha(sha)
142147
index=self._index_by_name(name)
143148

144-
defis_tree_cache(inp:Tuple[bytes,int,str])->TypeGuard[TreeCacheTup]:
145-
returnisinstance(inp[0],bytes)andisinstance(inp[1],int)andisinstance([inp],str)
146-
147149
item= (sha,mode,name)
148-
assertis_tree_cache(item)
150+
#assert is_tree_cache(item)
149151

150152
ifindex==-1:
151153
self._cache.append(item)
@@ -223,12 +225,12 @@ def _set_cache_(self, attr: str) -> None:
223225
ifattr=="_cache":
224226
# Set the data when we need it
225227
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())
227229
else:
228230
super(Tree,self)._set_cache_(attr)
229231
# END handle attribute
230232

231-
def_iter_convert_to_object(self,iterable:Iterable[Tuple[bytes,int,str]]
233+
def_iter_convert_to_object(self,iterable:Iterable[TreeCacheTup]
232234
)->Iterator[IndexObjUnion]:
233235
"""Iterable yields tuples of (binsha, mode, name), which will be converted
234236
to the respective object representation"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp