Skip to content

late-future-import

Pythoncorrectnessno fixdefault: warnpython/ruff

Reports a from __future__ import that comes after other statements.

Python rejects the file with SyntaxError: from __future__ imports must occur at the beginning of the file. Only a docstring, comments and other future imports may come before it.

To fix, move the import to the top.

Reported
...
from __future__ import annotations
...
import re
...
python:
lint:
rules:
late-future-import: warn # off, warn (default), error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line late-future-import in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ruff F404 full