-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
I was running mypy on an existing project, and the following code (recommended by the python datetime docs) ran into an error in mypy, which seems to stem from typeshed.
datetime.fromtimestamp(timestamp, timezone.utc)
Error from mypy is Argument 2 to "fromtimestamp" of "datetime" has incompatible type "tzinfo"; expected "timezone"
It looks like fromtimestamp expects an instance of timezone, but timezone.utc is stubbed as a tzinfo class, which looks like a parent of timezone?
Relevant sections in /stdlib/3/datetime.pyi are lines 16-19
class timezone(tzinfo):
utc = ... # type: tzinfo
min = ... # type: tzinfo
max = ... # type: tzinfo
and 175-ish, under class datetime:
@classmethod
def fromtimestamp(cls, t: float, tz: timezone = ...) -> datetime: ...
Metadata
Metadata
Assignees
Labels
No labels