mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-01 17:32:25 +00:00
648 B
648 B
missing-required-import (I002)
Derived from the isort linter.
Autofix is always available.
What it does
Adds any required imports, as specified by the user, to the top of the file.
Why is this bad?
In some projects, certain imports are required to be present in all files. For
example, some projects assume that from __future__ import annotations
is enabled,
and thus require that import to be present in all files. Omitting a "required" import
(as specified by the user) can cause errors or unexpected behavior.
Example
import typing
Use instead:
from __future__ import annotations
import typing