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

Commitf4cb7db

Browse files
committed
Change type of list_traverse() again.
1 parent1faa25f commitf4cb7db

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

‎git/objects/util.py‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from .tagimportTagObject
3333
from .treeimportTree,TraversedTreeTup
3434
fromsubprocessimportPopen
35+
from .submodule.baseimportSubmodule
3536

3637

3738
T_TIobj=TypeVar('T_TIobj',bound='TraversableIterableObj')# for TraversableIterableObj.traverse()
@@ -306,18 +307,28 @@ class Tree:: (cls, Tree) -> Tuple[Tree, ...]
306307
"""
307308
raiseNotImplementedError("To be implemented in subclass")
308309

309-
deflist_traverse(self,*args:Any,**kwargs:Any)->IterableList:
310+
deflist_traverse(self,*args:Any,**kwargs:Any)->IterableList[Union['Commit','Submodule','Tree','Blob']]:
310311
"""
311312
:return: IterableList with the results of the traversal as produced by
312313
traverse()
314+
Commit -> IterableList['Commit']
315+
Submodule -> IterableList['Submodule']
316+
Tree -> IterableList[Union['Submodule', 'Tree', 'Blob']]
313317
"""
314-
ifisinstance(self,TraversableIterableObj):
318+
# Commit and Submodule have id.__attribute__ as IterableObj
319+
# Tree has id.__attribute__ inherited from IndexObject
320+
ifisinstance(self, (TraversableIterableObj,Tree)):
315321
id=self._id_attribute_
316-
else:# Tree
317-
id=""
322+
else:
323+
id=""# shouldn't reach here, unless Traversable subclass created with no _id_attribute_
324+
# could add _id_attribute_ to Traversable, or make all Traversable also Iterable?
325+
326+
out:IterableList[Union['Commit','Submodule','Tree','Blob']]=IterableList(id)
327+
# overloads in subclasses (mypy does't allow typing self: subclass)
328+
# Union[IterableList['Commit'], IterableList['Submodule'], IterableList[Union['Submodule', 'Tree', 'Blob']]]
318329

319-
out:IterableList=IterableList(id)
320-
out.extend(self.traverse(*args,**kwargs))
330+
# NOTE: if is_edge=True, self.traverse returns a Tuple, so should be prevented or flattened?
331+
out.extend(self.traverse(*args,**kwargs))# type: ignore
321332
returnout
322333

323334
deftraverse(self,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp