Closed ethereon closed 1 month ago
Yes, this is by design and in conformance with the Python typing spec. The rules for .pyi
files are defined here. If you use the from .jam import buy
, a type checker assumes that buy
was imported for local use in __init__.pyi
and is not intended to be re-exported. If you want to re-export it, you need to use a redundant import form (from .jam import buy as buy
).
Consider the following toy typestub module:
strawberry/__init__.pyi
:strawberry/jam.pyi
:Pyright seems to provide different hover results depending on whether
Variant 1
(explicit import by name) orVariant 2
(wildcard import) is used in__init__.pyi
.For instance, requesting hover results at
buy
in the usagefrom strawberry import buy
:Variant 1
fails to resolve:Variant 2
works correctly:This only seems to occur with
.pyi
files. For regular Python modules, both variants seem to work correctly.Tested with
Pyright language server 1.1.375
/ recent main (https://github.com/microsoft/pyright/commit/de0386d690a85d844e721032fc517c4403a98984)