Skip to content

[red-knot] implement re-export conventions for imports #14099

@carljm

Description

@carljm

See https://typing.readthedocs.io/en/latest/spec/distributing.html#import-conventions

A normal from foo import bar in module a should not allow another module to do from a import bar; an explicit from foo import bar as bar should be required to specify a re-export.

In the current typing spec, these rules are worded as applicable to all modules. Mypy does apply them in all modules, pyright applies them only in type stubs.

I have a vague memory that these originated as stub-only conventions, but I haven't been able to dig up confirmation.

We need to decide if we will apply these conventions in all modules, or only in stubs, and then implement them accordingly.

In particular this is problematic at the moment because we don't apply these conventions in builtins.pyi, meaning we understand all symbols imported into builtins.pyi (e.g. various typing module symbols) as builtin names.

Metadata

Metadata

Assignees

Labels

tyMulti-file analysis & type inference

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions