Deprecate Git.USE_SHELL by EliahKagan · Pull Request #1787 · gitpython-developers/GitPython
TraversedTup = Union[ Tuple[Union["Traversable", None], "Traversable"], # For commit, submodule "TraversedTreeTup", ] # for tree.traverse() Tuple[Union["Traversable", None], "Traversable"], # For Commit, Submodule. "TraversedTreeTup", # For Tree.traverse(). ]
# --------------------------------------------------------------------
@abstractmethod def list_traverse(self, *args: Any, **kwargs: Any) -> Any: """ """ """Traverse self and collect all items found.
Calling this directly only the abstract base class, including via a ``super()`` proxy, is deprecated. Only overridden implementations should be called. """ warnings.warn( "list_traverse() method should only be called from subclasses." "Calling from Traversable abstract class will raise NotImplementedError in 3.1.20" "Builtin sublclasses are 'Submodule', 'Tree' and 'Commit", " Calling from Traversable abstract class will raise NotImplementedError in 4.0.0." " The concrete subclasses in GitPython itself are 'Commit', 'RootModule', 'Submodule', and 'Tree'.", DeprecationWarning, stacklevel=2, )
:return: IterableList with the results of the traversal as produced by traverse() Commit -> IterableList['Commit'] Submodule -> IterableList['Submodule'] Tree -> IterableList[Union['Submodule', 'Tree', 'Blob']] :meth:`traverse`::
Commit -> IterableList['Commit'] Submodule -> IterableList['Submodule'] Tree -> IterableList[Union['Submodule', 'Tree', 'Blob']] """ # Commit and Submodule have id.__attribute__ as IterableObj. # Tree has id.__attribute__ inherited from IndexObject.
@abstractmethod def traverse(self, *args: Any, **kwargs: Any) -> Any: """ """ """Iterator yielding items found when traversing self.
Calling this directly on the abstract base class, including via a ``super()`` proxy, is deprecated. Only overridden implementations should be called. """ warnings.warn( "traverse() method should only be called from subclasses." "Calling from Traversable abstract class will raise NotImplementedError in 3.1.20" "Builtin sublclasses are 'Submodule', 'Tree' and 'Commit", " Calling from Traversable abstract class will raise NotImplementedError in 4.0.0." " The concrete subclasses in GitPython itself are 'Commit', 'RootModule', 'Submodule', and 'Tree'.", DeprecationWarning, stacklevel=2, )
:param predicate: f(i,d) returns False if item i at depth d should not be included in the result.
""" Commit -> Iterator[Union[Commit, Tuple[Commit, Commit]] Submodule -> Iterator[Submodule, Tuple[Submodule, Submodule]] Tree -> Iterator[Union[Blob, Tree, Submodule, Tuple[Union[Submodule, Tree], Union[Blob, Tree, Submodule]]]
ignore_self=True is_edge=True -> Iterator[item] ignore_self=True is_edge=False --> Iterator[item] ignore_self=False is_edge=True -> Iterator[item] | Iterator[Tuple[src, item]] ignore_self=False is_edge=False -> Iterator[Tuple[src, item]] :return: Iterator yielding items found when traversing self::
Commit -> Iterator[Union[Commit, Tuple[Commit, Commit]] Submodule -> Iterator[Submodule, Tuple[Submodule, Submodule]] Tree -> Iterator[Union[Blob, Tree, Submodule, Tuple[Union[Submodule, Tree], Union[Blob, Tree, Submodule]]]
ignore_self=True is_edge=True -> Iterator[item] ignore_self=True is_edge=False --> Iterator[item] ignore_self=False is_edge=True -> Iterator[item] | Iterator[Tuple[src, item]] ignore_self=False is_edge=False -> Iterator[Tuple[src, item]] """
visited = set()
:note: A serialized object would ``_deserialize`` into the same object. :note: A serialized object would :meth:`_deserialize` into the same object.
:param stream: a file-like object
## To typecheck instead of using cast: # # import itertools # from git.types import TypeGuard # def is_commit_traversed(inp: Tuple) -> TypeGuard[Tuple[Iterator[Tuple['Commit', 'Commit']]]]: # for x in inp[1]: # if not isinstance(x, tuple) and len(x) != 2: # if all(isinstance(inner, Commit) for inner in x): # continue # return True # # ret = super(Commit, self).traverse(predicate, prune, depth, branch_first, visit_once, ignore_self, as_edge) # ret_tup = itertools.tee(ret, 2) # assert is_commit_traversed(ret_tup), f"{[type(x) for x in list(ret_tup[0])]}" # return ret_tup[0]
""" # To typecheck instead of using cast. import itertools from git.types import TypeGuard def is_commit_traversed(inp: Tuple) -> TypeGuard[Tuple[Iterator[Tuple['Commit', 'Commit']]]]: for x in inp[1]: if not isinstance(x, tuple) and len(x) != 2: if all(isinstance(inner, Commit) for inner in x): continue return True
ret = super(Commit, self).traverse(predicate, prune, depth, branch_first, visit_once, ignore_self, as_edge) ret_tup = itertools.tee(ret, 2) assert is_commit_traversed(ret_tup), f"{[type(x) for x in list(ret_tup[0])]}" return ret_tup[0] """ return cast( Union[Iterator[T_TIobj], Iterator[Tuple[Union[None, T_TIobj], T_TIobj]]], super()._traverse(predicate, prune, depth, branch_first, visit_once, ignore_self, as_edge), # type: ignore