type hint returns NameError: name 'datetime' not defined
Either import datetime
and use datetime.datetime
as hint, or from datetime import datetime
and use datetime
as hint.
You need to import datetime
, or use a string (remember, it is just an hint).
>>> def f(x: datetime):
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'datetime' is not defined
>>> def f(x: 'datetime'):
... pass
...
>>>
>>> from datetime import datetime
>>> def f(x: datetime):
... pass
...
>>>
Python 3.7.4