diff options
author | Yobmod <yobmod@gmail.com> | 2021-06-30 22:47:45 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-06-30 22:47:45 +0100 |
commit | a8ddf69c1268d2af6eff9179218ab61bcda1f6e5 (patch) | |
tree | 4305af24d08bf9b9ea74e436dc92a1599e4bb9dc /git/util.py | |
parent | 237966a20a61237a475135ed8a13b90f65dcb2ca (diff) | |
download | gitpython-a8ddf69c1268d2af6eff9179218ab61bcda1f6e5.tar.gz |
Type Traversable/list_traverse() better, make IterablleObj a protocol
Diffstat (limited to 'git/util.py')
-rw-r--r-- | git/util.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/git/util.py b/git/util.py index 057d7478..ebb119b9 100644 --- a/git/util.py +++ b/git/util.py @@ -27,7 +27,7 @@ import warnings # typing --------------------------------------------------------- -from typing import (Any, AnyStr, BinaryIO, Callable, Dict, Generator, IO, Iterable as typIter, Iterator, List, +from typing import (Any, AnyStr, BinaryIO, Callable, Dict, Generator, IO, Iterator, List, Optional, Pattern, Sequence, Tuple, TypeVar, Union, cast, TYPE_CHECKING, overload) import pathlib @@ -37,9 +37,10 @@ if TYPE_CHECKING: from git.repo.base import Repo from git.config import GitConfigParser, SectionConstraint -from .types import PathLike, Literal, SupportsIndex, HSH_TD, Total_TD, Files_TD +from .types import (Literal, Protocol, SupportsIndex, # because behind py version guards + PathLike, HSH_TD, Total_TD, Files_TD) # aliases -T_IterableObj = TypeVar('T_IterableObj', bound=Union['IterableObj', typIter], covariant=True) +T_IterableObj = TypeVar('T_IterableObj', bound='IterableObj', covariant=True) # So IterableList[Head] is subtype of IterableList[IterableObj] # --------------------------------------------------------------------- @@ -1065,7 +1066,7 @@ class Iterable(object): raise NotImplementedError("To be implemented by Subclass") -class IterableObj(): +class IterableObj(Protocol): """Defines an interface for iterable items which is to assure a uniform way to retrieve and iterate items within the git repository |