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
tidy-imports seems to complain about every other type annotation that uses a forward reference:
$ tidy-imports --diff <<END
from __future__ import annotations
def f1(x: X) -> None:
pass
def f2(x: X) -> None:
pass
def f3(x: X) -> None:
pass
def f4(x: X) -> None:
pass
class X:
pass
END
[PYFLYBY] /dev/stdin:6: undefined name 'X' and no known import for it
[PYFLYBY] /dev/stdin:12: undefined name 'X' and no known import for it
Strictly speaking, if the annotations future feature is being used then the annotations can contain arbitrary values, since Python won't try to evaluate them, but in practice it's probably fine to assume that they are being used as type annotations and can be evaluated.
Forward references without using the annotations future feature work:
I think this is a deeper problem with Pyflyby, as the codebase is designed to do depth first search in a single pass there is always scoping issues, and every time we have a problem with this we add a band aid and special casing.
IMHO it will be hard to consistency fix those without a major rewrite, and having those checks be done in multiple passes to properly apply python scoping rules.
tidy-imports seems to complain about every other type annotation that uses a forward reference:
Strictly speaking, if the annotations future feature is being used then the annotations can contain arbitrary values, since Python won't try to evaluate them, but in practice it's probably fine to assume that they are being used as type annotations and can be evaluated.
Forward references without using the annotations future feature work:
The text was updated successfully, but these errors were encountered: