You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is clearly OK and works without the future import. With the future import it produces:
File "/home/elt/code/pytype-test/proj/local_import.py", line 6, in test: Name 'datetime' is not defined [name-error]
File "/home/elt/code/pytype-test/proj/local_import.py", line 9, in test: Name 'datetime' is not defined [name-error]
The text was updated successfully, but these errors were encountered:
going to close this as infeasible - future annotations are effectively deprecated (they will never become the default behaviour in python, and i would be unsurprised if they are removed from __future__ at some point). furthermore local imports are a poorly-supported feature at best (and low-priority for pytype) so this is simply an unfortunate confluence of features.
this pydantic thread outlines some of the issues with future annotations; it doesn't apply identically to pytype's situation but it is a good illustration of the ways in which they are problematic.
When using
from __future__ import annotations
, locally imported names cannot be used in type annotations. Example:This is clearly OK and works without the future import. With the future import it produces:
The text was updated successfully, but these errors were encountered: