Skip to content

Add support for string type hint in typing.Annotated #10279

@minmax

Description

@minmax

String type hints used in Annotated should be imported in TYPE_CHECKING section, but ruff remove imports for now.
I think ruff should treat the first argument of Annotated similar to the current behavior for ClassVar.

from types import FunctionType  # `types.FunctionType` imported but unused F401
from typing import Annotated

Func = Annotated["FunctionType", int]

ruff 0.3.0

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