Skip to content

Don't mark re-exported symbols as unused (F401) #717

@layday

Description

@layday

Currently, an import in the form of:

from a import b as b

will trigger F401, but this idiom is in widespread use as a type checker-friendly alternative to __all__ which does not alter star import semantics. Type checkers which support flagging unused imports will ignore re-exported symbols, i.e. symbols where the as target is identical to the original name:

# pyright: strict

from os import environ  # Pyright reports this as unused
from os import environ as foo  # Likewise
from os import environb as environb   # No error

Thanks for ruff!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions