mirror of
https://github.com/microsoft/pyright.git
synced 2024-08-16 19:30:26 +03:00
Further clarified in the typed libraries docs that “from .A import X” form is honored only in “__init__.py”.
This commit is contained in:
parent
b5017de462
commit
36d499cada
@ -32,7 +32,7 @@ If a “py.typed” module is present, a type checker will treat all modules wit
|
||||
Each module exposes a set of symbols. Some of these symbols are considered “private” — implementation details that are not part of the library’s interface. Type checkers like pyright use the following rules to determine which symbols are visible outside of the package.
|
||||
|
||||
* Symbols whose names begin with an underscore (but are not dunder names) are considered private.
|
||||
* Imported symbols are considered private by default. If they use the “import A as A” (a redundant module alias), “from X import A as A” (a redundant symbol alias), “from . import A”, or “from .A import X” forms, symbol “A” is not private unless the name begins with an underscore. Likewise, if a wildcard import (of the form “from X import *”) is used, all symbols referenced by the wildcard are not private.
|
||||
* Imported symbols are considered private by default. If they use the “import A as A” (a redundant module alias), “from X import A as A” (a redundant symbol alias), or “from . import A” forms, symbol “A” is not private unless the name begins with an underscore. If a file `__init__.py` uses form “from .A import X”, symbol “A” is treated likewise. If a wildcard import (of the form “from X import *”) is used, all symbols referenced by the wildcard are not private.
|
||||
* A module can expose an `__all__` symbol at the module level that provides a list of names that are considered part of the interface. This overrides all other rules above, allowing imported symbols or symbols whose names begin with an underscore to be included in the interface.
|
||||
* Local variables within a function (including nested functions) are always considered private.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user