Clarification on "private" modules in a package #7850
Unanswered
Sangeppato
asked this question in
Q&A
Replies: 1 comment
-
Your understanding is correct. I would expect that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In Typing Guidance for Python Libraries it is stated that "a type checker will treat all modules within that package as importable unless the module is marked private" and: "If a file
__init__.py
uses the formfrom .A import X
, symbol “A” is not private unless the name begins with an underscore".I have the following package structure:
pkg/__init__.py
:pkg/subpkg/__init__.py
:When using autocompletion with Pylance in VSCode, I can see that imported symbols in
b.py
(such asnumpy
andmath
) are correctly considered "private" and thus not visible in the completion pop-up. On the other hand, when completingpkg.subpkg.
I can see the submodule_a
as importable. Maybe I didn't understand it properly, but considering the aforementioned statement I would expect_a
to be considered private and omitted from the autocompletion suggestions. Is there anything I'm missing? Is there a way to prevent implementation modules such as_a
from appearing in the completion pop-up? Thank you in advance.Beta Was this translation helpful? Give feedback.
All reactions