summaryrefslogtreecommitdiff
path: root/git/objects/util.py
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-08-02 14:56:03 +0100
committerYobmod <yobmod@gmail.com>2021-08-02 14:56:03 +0100
commit91fce331de16de6039c94cd4d7314184a5763e61 (patch)
treee0ef280c84bddf90be0651f414b54689bcc3070b /git/objects/util.py
parent0525c17bc287a54bd670919a374e226345d96260 (diff)
downloadgitpython-91fce331de16de6039c94cd4d7314184a5763e61.tar.gz
increase mypy strictness (warn unused ignored and warn unreachable)
Diffstat (limited to 'git/objects/util.py')
-rw-r--r--git/objects/util.py8
1 files changed, 5 insertions, 3 deletions
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_