diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2021-07-20 07:04:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 07:04:18 +0800 |
commit | cfd653aeeb3cb807f2cd2ae9fff5568880ac67da (patch) | |
tree | 8514389e82efdcdcdeaab5d3a85553883f28117c /git/objects/tree.py | |
parent | acbd6bad9ded9a1d59e80e71d334d64b0244f5cd (diff) | |
parent | 600df043e76924d43a4f9f88f4e3241740f34c77 (diff) | |
download | gitpython-cfd653aeeb3cb807f2cd2ae9fff5568880ac67da.tar.gz |
Merge pull request #1295 from Yobmod/main
Add types to refs
Diffstat (limited to 'git/objects/tree.py')
-rw-r--r-- | git/objects/tree.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/git/objects/tree.py b/git/objects/tree.py index a9656c1d..dd1fe783 100644 --- a/git/objects/tree.py +++ b/git/objects/tree.py @@ -24,7 +24,7 @@ from .fun import ( from typing import (Any, Callable, Dict, Iterable, Iterator, List, Tuple, Type, Union, cast, TYPE_CHECKING) -from git.types import PathLike, TypeGuard +from git.types import PathLike, TypeGuard, Literal if TYPE_CHECKING: from git.repo import Repo @@ -195,7 +195,7 @@ class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable): blob = tree[0] """ - type = "tree" + type: Literal['tree'] = "tree" __slots__ = "_cache" # actual integer ids for comparison @@ -285,7 +285,7 @@ class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable): return [i for i in self if i.type == "tree"] @ property - def blobs(self) -> List['Blob']: + def blobs(self) -> List[Blob]: """:return: list(Blob, ...) list of blobs directly below this tree""" return [i for i in self if i.type == "blob"] @@ -298,7 +298,7 @@ class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable): See the ``TreeModifier`` for more information on how to alter the cache""" return TreeModifier(self._cache) - def traverse(self, # type: ignore # overrides super() + def traverse(self, # type: ignore[override] predicate: Callable[[Union[IndexObjUnion, TraversedTreeTup], int], bool] = lambda i, d: True, prune: Callable[[Union[IndexObjUnion, TraversedTreeTup], int], bool] = lambda i, d: False, depth: int = -1, @@ -322,8 +322,8 @@ class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable): # assert is_tree_traversed(ret_tup), f"Type is {[type(x) for x in list(ret_tup[0])]}" # return ret_tup[0]""" return cast(Union[Iterator[IndexObjUnion], Iterator[TraversedTreeTup]], - super(Tree, self).traverse(predicate, prune, depth, # type: ignore - branch_first, visit_once, ignore_self)) + super(Tree, self)._traverse(predicate, prune, depth, # type: ignore + branch_first, visit_once, ignore_self)) def list_traverse(self, *args: Any, **kwargs: Any) -> IterableList[IndexObjUnion]: """ @@ -331,7 +331,7 @@ class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable): traverse() Tree -> IterableList[Union['Submodule', 'Tree', 'Blob']] """ - return super(Tree, self).list_traverse(* args, **kwargs) + return super(Tree, self)._list_traverse(* args, **kwargs) # List protocol |