Skip to content

Commit

Permalink
mypy-friendly compat functions handling
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Nov 1, 2020
1 parent 3a9e3e0 commit 96be32a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions my/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,24 @@ def __get__(self, obj: None, cls: _C) -> _R:

fromisoformat: Callable[[str], datetime]
import sys
if sys.version_info.minor >= 7:
if sys.version_info[:2] >= (3, 7):
# prevent mypy on py3.6 from complaining...
fromisoformat_real = datetime.fromisoformat # type: ignore[attr-defined]
fromisoformat_real = datetime.fromisoformat
fromisoformat = fromisoformat_real
else:
from .py37 import fromisoformat


if sys.version_info[:2] >= (3, 8):
from typing import Literal
else:
if TYPE_CHECKING:
from typing_extensions import Literal
else:
# erm.. I guess as long as it's not crashing, whatever...
Literal = Union


# TODO doctests?
def isoparse(s: str) -> tzdatetime:
"""
Expand Down
2 changes: 1 addition & 1 deletion my/time/tz/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def default_policy() -> Policy:
return cast(Policy, user_config.tz.policy)
except Exception as e:
# todo meh.. need to think how to do this more carefully
# rationale: do not mess with user's data until they want
# rationale: do not mess with user's data unless they want
return 'keep'


Expand Down

0 comments on commit 96be32a

Please sign in to comment.