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.
See https://typing.readthedocs.io/en/latest/spec/distributing.html#import-conventions
A normal
from foo import barin moduleashould not allow another module to dofrom a import bar; an explicitfrom foo import bar as barshould 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 intobuiltins.pyi(e.g. varioustypingmodule symbols) as builtin names.