diff options
author | Yobmod <yobmod@gmail.com> | 2021-08-02 14:56:03 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-08-02 14:56:03 +0100 |
commit | 91fce331de16de6039c94cd4d7314184a5763e61 (patch) | |
tree | e0ef280c84bddf90be0651f414b54689bcc3070b /git/objects | |
parent | 0525c17bc287a54bd670919a374e226345d96260 (diff) | |
download | gitpython-91fce331de16de6039c94cd4d7314184a5763e61.tar.gz |
increase mypy strictness (warn unused ignored and warn unreachable)
Diffstat (limited to 'git/objects')
-rw-r--r-- | git/objects/fun.py | 2 | ||||
-rw-r--r-- | git/objects/tree.py | 2 | ||||
-rw-r--r-- | git/objects/util.py | 8 |
3 files changed, 7 insertions, 5 deletions
diff --git a/git/objects/fun.py b/git/objects/fun.py index d6cdafe1..19b4e525 100644 --- a/git/objects/fun.py +++ b/git/objects/fun.py @@ -51,7 +51,7 @@ def tree_to_stream(entries: Sequence[EntryTup], write: Callable[['ReadableBuffer if isinstance(name, str): name_bytes = name.encode(defenc) else: - name_bytes = name + name_bytes = name # type: ignore[unreachable] # check runtime types - is always str? write(b''.join((mode_str, b' ', name_bytes, b'\0', binsha))) # END for each item diff --git a/git/objects/tree.py b/git/objects/tree.py index 0cceb59a..22531895 100644 --- a/git/objects/tree.py +++ b/git/objects/tree.py @@ -215,7 +215,7 @@ class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable): super(Tree, self).__init__(repo, binsha, mode, path) @ classmethod - def _get_intermediate_items(cls, index_object: 'Tree', + def _get_intermediate_items(cls, index_object: IndexObjUnion, ) -> Union[Tuple['Tree', ...], Tuple[()]]: if index_object.type == "tree": return tuple(index_object._iter_convert_to_object(index_object._cache)) diff --git a/git/objects/util.py b/git/objects/util.py index d3842cfb..9c9ce773 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -167,7 +167,7 @@ def from_timestamp(timestamp: float, tz_offset: float) -> datetime: return utc_dt -def parse_date(string_date: str) -> Tuple[int, int]: +def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]: """ Parse the given date as one of the following @@ -182,8 +182,10 @@ def parse_date(string_date: str) -> Tuple[int, int]: :note: Date can also be YYYY.MM.DD, MM/DD/YYYY and DD.MM.YYYY. """ if isinstance(string_date, datetime) and string_date.tzinfo: - offset = -int(string_date.utcoffset().total_seconds()) + offset = -int(string_date.utcoffset().total_seconds()) # type: ignore[union-attr] return int(string_date.astimezone(utc).timestamp()), offset + else: + assert isinstance(string_date, str) # for mypy # git time try: @@ -338,7 +340,7 @@ class Traversable(Protocol): """ # Commit and Submodule have id.__attribute__ as IterableObj # Tree has id.__attribute__ inherited from IndexObject - if isinstance(self, (TraversableIterableObj, Has_id_attribute)): + if isinstance(self, Has_id_attribute): id = self._id_attribute_ else: id = "" # shouldn't reach here, unless Traversable subclass created with no _id_attribute_ |