diff options
| author | Yobmod <yobmod@gmail.com> | 2021-07-09 10:33:12 +0100 |
|---|---|---|
| committer | Yobmod <yobmod@gmail.com> | 2021-07-09 10:33:12 +0100 |
| commit | 3710e24d6b60213454af10b0dc0ff0c49717169f (patch) | |
| tree | ef1d954d0c3e5b4ddabe7f04c76c2e454dfbb9ec /git/objects | |
| parent | 030b1fded8b8e1bcf3855beaf9035b4e3e755f5c (diff) | |
| download | gitpython-3710e24d6b60213454af10b0dc0ff0c49717169f.tar.gz | |
Rmv circular import, create Has_id_attribute Protocol instead
Diffstat (limited to 'git/objects')
| -rw-r--r-- | git/objects/tree.py | 2 | ||||
| -rw-r--r-- | git/objects/util.py | 6 |
2 files changed, 3 insertions, 5 deletions
diff --git a/git/objects/tree.py b/git/objects/tree.py index 804554d8..e168c6c4 100644 --- a/git/objects/tree.py +++ b/git/objects/tree.py @@ -323,7 +323,7 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable): super(Tree, self).traverse(predicate, prune, depth, # type: ignore branch_first, visit_once, ignore_self)) - def list_traverse(self, *args: Any, **kwargs: Any) -> IterableList[Union['Tree', 'Submodule', 'Blob']]: + def list_traverse(self, *args: Any, **kwargs: Any) -> IterableList[IndexObjUnion]: return super(Tree, self).list_traverse(* args, **kwargs) # List protocol diff --git a/git/objects/util.py b/git/objects/util.py index 4dce0aee..1c266563 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -19,13 +19,11 @@ import time import calendar from datetime import datetime, timedelta, tzinfo -from git.objects.base import IndexObject # just for an isinstance check - # typing ------------------------------------------------------------ from typing import (Any, Callable, Deque, Iterator, NamedTuple, overload, Sequence, TYPE_CHECKING, Tuple, Type, TypeVar, Union, cast) -from git.types import Literal +from git.types import Has_id_attribute, Literal if TYPE_CHECKING: from io import BytesIO, StringIO @@ -319,7 +317,7 @@ class Traversable(object): """ # Commit and Submodule have id.__attribute__ as IterableObj # Tree has id.__attribute__ inherited from IndexObject - if isinstance(self, (TraversableIterableObj, IndexObject)): + if isinstance(self, (TraversableIterableObj, Has_id_attribute)): id = self._id_attribute_ else: id = "" # shouldn't reach here, unless Traversable subclass created with no _id_attribute_ |
