diff options
| author | Yobmod <yobmod@gmail.com> | 2021-07-19 19:10:45 +0100 |
|---|---|---|
| committer | Yobmod <yobmod@gmail.com> | 2021-07-19 19:10:45 +0100 |
| commit | 9e5e969479ec6018e1ba06b95bcdefca5b0082a4 (patch) | |
| tree | 574e03c6c4acd1067e3b285974651ec9e9529a49 /git/objects | |
| parent | 9a587e14d509cc77bf47b9591d1def3e5a1df570 (diff) | |
| download | gitpython-9e5e969479ec6018e1ba06b95bcdefca5b0082a4.tar.gz | |
Change remaining type comments to py3.6+ types
Diffstat (limited to 'git/objects')
| -rw-r--r-- | git/objects/submodule/base.py | 3 | ||||
| -rw-r--r-- | git/objects/tag.py | 4 | ||||
| -rw-r--r-- | git/objects/tree.py | 2 | ||||
| -rw-r--r-- | git/objects/util.py | 6 |
4 files changed, 8 insertions, 7 deletions
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index 21cfcd5a..d5ba118f 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -475,7 +475,8 @@ class Submodule(IndexObject, TraversableIterableObj): sm._branch_path = br.path # we deliberately assume that our head matches our index ! - sm.binsha = mrepo.head.commit.binsha # type: ignore + if mrepo: + sm.binsha = mrepo.head.commit.binsha index.add([sm], write=True) return sm diff --git a/git/objects/tag.py b/git/objects/tag.py index 4a2fcb0d..7048eb40 100644 --- a/git/objects/tag.py +++ b/git/objects/tag.py @@ -51,7 +51,7 @@ class TagObject(base.Object): authored_date is in, in a format similar to time.altzone""" super(TagObject, self).__init__(repo, binsha) if object is not None: - self.object = object # type: Union['Commit', 'Blob', 'Tree', 'TagObject'] + self.object: Union['Commit', 'Blob', 'Tree', 'TagObject'] = object if tag is not None: self.tag = tag if tagger is not None: @@ -67,7 +67,7 @@ class TagObject(base.Object): """Cache all our attributes at once""" if attr in TagObject.__slots__: ostream = self.repo.odb.stream(self.binsha) - lines = ostream.read().decode(defenc, 'replace').splitlines() # type: List[str] + lines: List[str] = ostream.read().decode(defenc, 'replace').splitlines() _obj, hexsha = lines[0].split(" ") _type_token, type_name = lines[1].split(" ") diff --git a/git/objects/tree.py b/git/objects/tree.py index 0e3f44b9..dd1fe783 100644 --- a/git/objects/tree.py +++ b/git/objects/tree.py @@ -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, diff --git a/git/objects/util.py b/git/objects/util.py index 04af3b83..ef1ae77b 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -285,7 +285,7 @@ class ProcessStreamAdapter(object): def __init__(self, process: 'Popen', stream_name: str) -> None: self._proc = process - self._stream = getattr(process, stream_name) # type: StringIO ## guess + self._stream: StringIO = getattr(process, stream_name) # guessed type def __getattr__(self, attr: str) -> Any: return getattr(self._stream, attr) @@ -356,7 +356,7 @@ class Traversable(Protocol): return out_list @ abstractmethod - def traverse(self, *args: Any, **kwargs) -> Any: + def traverse(self, *args: Any, **kwargs: Any) -> Any: """ """ warnings.warn("traverse() method should only be called from subclasses." "Calling from Traversable abstract class will raise NotImplementedError in 3.1.20" @@ -414,7 +414,7 @@ class Traversable(Protocol): ignore_self=False is_edge=False -> Iterator[Tuple[src, item]]""" visited = set() - stack = deque() # type: Deque[TraverseNT] + stack: Deque[TraverseNT] = deque() stack.append(TraverseNT(0, self, None)) # self is always depth level 0 def addToStack(stack: Deque[TraverseNT], |
