pyre-check
pyre-check copied to clipboard
Detect import problems with __future__
Pyre Feature Request
Detect when the import of from __future__ import annotations
is not the first import in a file and create an error for it.
Is your feature request related to a problem? Please describe.
My library has nested data models similar to the following:
from dataclasses import dataclass
from __future__ import annotations
class Foo:
children: list[Foo] | None = None
Pyre accepts this, but when run in Python, it reports the following error:
File "C:\myfiles\foo.py", line 16
from __future__ import annotations
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: from __future__ imports must occur at the beginning of the file
Describe the solution you'd like Pyre should report an error if this import statement is not at the beginning of the file.