Skip to content

unsorted-imports (I001) false positive when import __future__ is below from __future__ import #8823

@DetachHead

Description

@DetachHead
from __future__ import annotations  # I001: Import block is un-sorted or un-formatted
import __future__

https://play.ruff.rs/064dd932-8bfa-447c-b8a6-458a27ac6ba4

running ruf --fix causes F404 and a runtime syntax error:

import __future__  # F404: `from __future__` imports must occur at the beginning of the file
from __future__ import annotations
SyntaxError: from __future__ imports must occur at the beginning of the file

(i can't think of a reason you'd ever want to import the whole __future__ module so this is probably low priority)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions