-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stub methods for abstract tzinfo to allow usage with mypy 1.0.0 #126
base: master
Are you sure you want to change the base?
Conversation
Hm. Kind of a weird choice on |
Fixes pganssle#125. Ported from: python/typeshed@de0b366 Signed-off-by: Anders Kaseorg <[email protected]>
@@ -30,6 +30,9 @@ class ZoneInfo(tzinfo): | |||
) -> _T: ... | |||
@classmethod | |||
def clear_cache(cls, *, only_keys: Iterable[str] = ...) -> None: ... | |||
def tzname(self, __dt: datetime | None) -> str | None: ... | |||
def utcoffset(self, __dt: datetime | None) -> timedelta | None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not too concerned with this since it's maybe better taken up with typeshed
, but I am not sure that these are actually the right type signatures for these functions.
They can take a time
as well, and they never return None
if you pass them a datetime
, so the correct signatures are probably:
@overload
def utcoffset(self, __dt: datetime) -> timedelta: ...
@overload
def utcoffset(self, __dt: Union[time, None]) -> Union[timedelta, None]: ...
I created a PR upstream in typeshed
for discussion: python/typeshed#9862
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I continue to request that this be merged as-is, because the purpose of a backport is to optimize compatibility with the released upstream version, not to pursue incompatible improvements. Obviously you’re welcome to continue pursuing those improvements upstream, and then we can backport them here in the future. But there’s no reason to block this current backport on that.
The typeshed and mypy issues aren’t going to be straightforward to resolve. Would you be open to merging and releasing this now, so that the library can be used with mypy ≥ 1.0.0, and we can later update it for future typeshed and mypy fixes as appropriate? |
Fixes #125. Ported from python/typeshed@de0b366.