diff options
author | Yobmod <yobmod@gmail.com> | 2021-05-20 20:44:53 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-05-20 20:44:53 +0100 |
commit | 5402a166a4971512f9d513bf36159dead9672ae9 (patch) | |
tree | ced858bf72b6c9f0f594d54f44db04e91abc0da6 /git/objects/tree.py | |
parent | c242b55d7c64ee43405f8b335c762bcf92189d38 (diff) | |
download | gitpython-5402a166a4971512f9d513bf36159dead9672ae9.tar.gz |
Add types to objects _get_intermediate_items()
Diffstat (limited to 'git/objects/tree.py')
-rw-r--r-- | git/objects/tree.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/git/objects/tree.py b/git/objects/tree.py index 68e98329..65c9be4c 100644 --- a/git/objects/tree.py +++ b/git/objects/tree.py @@ -3,6 +3,7 @@ # # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php +from typing import Iterable, Iterator, Tuple, Union, cast from git.util import join_path import git.diff as diff from git.util import to_bin_sha @@ -182,8 +183,10 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable): super(Tree, self).__init__(repo, binsha, mode, path) @classmethod - def _get_intermediate_items(cls, index_object): + def _get_intermediate_items(cls, index_object: 'Tree', # type: ignore + ) -> Tuple['Tree', ...]: if index_object.type == "tree": + index_object = cast('Tree', index_object) return tuple(index_object._iter_convert_to_object(index_object._cache)) return () @@ -196,7 +199,8 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable): super(Tree, self)._set_cache_(attr) # END handle attribute - def _iter_convert_to_object(self, iterable): + def _iter_convert_to_object(self, iterable: Iterable[Tuple[bytes, int, str]] + ) -> Iterator[Union[Blob, 'Tree', Submodule]]: """Iterable yields tuples of (binsha, mode, name), which will be converted to the respective object representation""" for binsha, mode, name in iterable: |