-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
datetime.datetime
and datetime.date
types cannot be used interchangeably, but the inheritance specified by the types in this project imply that they can. Consider the following code:
import datetime
def foo(d: datetime.date):
return d < datetime.date.today()
foo(datetime.datetime.now()) # raises TypeError: can't compare datetime.datetime to datetime.date
Typechecking should indicate a problem - but it doesn't, resulting in a runtime exception instead.
I raised this issue with the Pyright project, but was redirected here.
m-aciek and GiorgioBalestrieri
Metadata
Metadata
Assignees
Labels
No labels