summaryrefslogtreecommitdiff
path: root/git/objects/util.py
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-08-02 16:16:11 +0100
committerYobmod <yobmod@gmail.com>2021-08-02 16:16:11 +0100
commit13e0730b449e8ace2c7aa691d588febb4bed510c (patch)
treeabf26124f626e0d437eb10719a576fdfc136afa6 /git/objects/util.py
parent829142d4c30886db2a2622605092072e979afcc9 (diff)
downloadgitpython-13e0730b449e8ace2c7aa691d588febb4bed510c.tar.gz
Fix parse_date typing
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 9c9ce773..d7472b5d 100644
--- a/git/objects/util.py
+++ b/git/objects/util.py
@@ -181,11 +181,13 @@ def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]:
:raise ValueError: If the format could not be understood
: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()) # type: ignore[union-attr]
+ if isinstance(string_date, datetime):
+ if string_date.tzinfo:
+ utcoffset = string_date.utcoffset()
+ offset = -int(utcoffset.total_seconds()) if utcoffset else 0
return int(string_date.astimezone(utc).timestamp()), offset
else:
- assert isinstance(string_date, str) # for mypy
+ assert isinstance(string_date, str), f"string_date={string_date}, type={type(string_date)}" # for mypy
# git time
try: