summaryrefslogtreecommitdiff
path: root/git/objects/tree.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/objects/tree.py')
-rw-r--r--git/objects/tree.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/git/objects/tree.py b/git/objects/tree.py
index 65c9be4c..29b2a684 100644
--- a/git/objects/tree.py
+++ b/git/objects/tree.py
@@ -3,7 +3,6 @@
#
# 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
@@ -18,6 +17,17 @@ from .fun import (
tree_to_stream
)
+
+# typing -------------------------------------------------
+
+from typing import Iterable, Iterator, Tuple, Union, cast, TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from io import BytesIO
+
+#--------------------------------------------------------
+
+
cmp = lambda a, b: (a > b) - (a < b)
__all__ = ("TreeModifier", "Tree")
@@ -321,7 +331,7 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
def __reversed__(self):
return reversed(self._iter_convert_to_object(self._cache))
- def _serialize(self, stream):
+ def _serialize(self, stream: 'BytesIO') -> 'Tree':
"""Serialize this tree into the stream. Please note that we will assume
our tree data to be in a sorted state. If this is not the case, serialization
will not generate a correct tree representation as these are assumed to be sorted
@@ -329,7 +339,7 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
tree_to_stream(self._cache, stream.write)
return self
- def _deserialize(self, stream):
+ def _deserialize(self, stream: 'BytesIO') -> 'Tree':
self._cache = tree_entries_from_data(stream.read())
return self