diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2021-06-26 10:09:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-26 10:09:53 +0800 |
commit | 2d2ff037f9f7a9ae33e5f4f6bdb75b669a1af19a (patch) | |
tree | 5f4fd00ad13fa5455dc876ab9cb9cc4f9b66bdfc /git/objects/util.py | |
parent | 703280b8c3df6f9b1a5cbe0997b717edbcaa8979 (diff) | |
parent | 5d7b8ba9f2e9298496232e4ae66bd904a1d71001 (diff) | |
download | gitpython-2d2ff037f9f7a9ae33e5f4f6bdb75b669a1af19a.tar.gz |
Merge pull request #1279 from Yobmod/main
Finish typing object, improve verious other types.
Diffstat (limited to 'git/objects/util.py')
-rw-r--r-- | git/objects/util.py | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/git/objects/util.py b/git/objects/util.py index 087f0166..8b8148a9 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -19,16 +19,18 @@ import calendar from datetime import datetime, timedelta, tzinfo # typing ------------------------------------------------------------ -from typing import (Any, Callable, Deque, Iterator, Sequence, TYPE_CHECKING, Tuple, Type, Union, cast, overload) +from typing import (Any, Callable, Deque, Iterator, TypeVar, TYPE_CHECKING, Tuple, Type, Union, cast) if TYPE_CHECKING: from io import BytesIO, StringIO - from .submodule.base import Submodule + from .submodule.base import Submodule # noqa: F401 from .commit import Commit from .blob import Blob from .tag import TagObject from .tree import Tree from subprocess import Popen + +T_Iterableobj = TypeVar('T_Iterableobj') # -------------------------------------------------------------------- @@ -284,29 +286,8 @@ class Traversable(object): """ __slots__ = () - @overload @classmethod - def _get_intermediate_items(cls, item: 'Commit') -> Tuple['Commit', ...]: - ... - - @overload - @classmethod - def _get_intermediate_items(cls, item: 'Submodule') -> Tuple['Submodule', ...]: - ... - - @overload - @classmethod - def _get_intermediate_items(cls, item: 'Tree') -> Tuple['Tree', ...]: - ... - - @overload - @classmethod - def _get_intermediate_items(cls, item: 'Traversable') -> Tuple['Traversable', ...]: - ... - - @classmethod - def _get_intermediate_items(cls, item: 'Traversable' - ) -> Sequence['Traversable']: + def _get_intermediate_items(cls, item): """ Returns: Tuple of items connected to the given item. @@ -322,7 +303,7 @@ class Traversable(object): """ :return: IterableList with the results of the traversal as produced by traverse()""" - out = IterableList(self._id_attribute_) # type: ignore[attr-defined] # defined in sublcasses + out: IterableList = IterableList(self._id_attribute_) # type: ignore[attr-defined] # defined in sublcasses out.extend(self.traverse(*args, **kwargs)) return out |