Wildcard imports trip up module discovery? not a known attribute of module
#6398
Labels
bug
Something isn't working
not a known attribute of module
#6398
Type: Bug
Hello Pylance crew! I know "Wildcard imports ... should be avoided" but we use them in some selected places for constants and common stuff.
Found
I'm experiencing some problems finding explicitly imported modules and their functions using wildcard imports.
So, I'm basically:
module.submodule1
module.submodule2
)module.submodule1
submodule1
submodule1
(is that a separate issue?)
goto submodule function definition and hover popup works right away as soon as the wildcard import is commented out or
import module.submodule2
is removed from the wildcard imported file, or when I explicitly define__all__
.Expected
The module should be found as it is in the live code or when stepping through with the debugger (Or when the
*
import is commented out), (Or when__all__
is set up in the wildcard imported module)Or there should be some information on the Pylance error on WHY this is the case like "wildcard imports make it impossible to guess how members of
module
are mangled. Use__all__
declaration."? 🤷♀️Repro
I was able to cook it down to this setup:
__init__.py
- root script importingmylib.a
and*
frommy_common_stuffs
my_common_stuffs.py
- importingmylib.b
mylib
__init__.py
- can be emptya.py
- defining some functionb.py
- can be emptyWhere the code in
my_common_stuffs.py
is as simple as:and in the root file it's like:
Extra
So while cooking the report I found that I should probably make use of
__all__
:)But still it seems broken with this simple setup especially as it's actually running fine at runtime and debug!
Info
Extension version: 2024.9.100 (pre-release)
VS Code version: Code 1.93.1 (38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, 2024-09-11T17:20:05.685Z)
OS version: Windows_NT x64 10.0.19045
Python Debugger: 2024.11.2024082901 (pre-release)
Modes:
A/B Experiments
The text was updated successfully, but these errors were encountered: