pylance-release
pylance-release copied to clipboard
six.moves marked as missing module source
Environment data
- Language Server version: 2021.5.3
- OS and version: OSX 10.14.6
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.1
Expected behaviour
six.moves should be resolved in the activated interpreter as six is.
Actual behaviour
reportMissingModuleSource error
six.moves appears to be a module that gets dynamically generated in memory by six.py at runtime and doesn't appear on disk (but, has a stub via typeshed), hence the "missing source" error. That's really unfortunate.
Yeah; pylint can find it because it actually constructs the AST. Tricky for static analysis that's for sure.
We can find it (as a stub in typeshed), it's just that we issue a warning when we can't find the source. I'm sure pylint has special cased this to not emit a message as it knows this popular module does something special.
Pylint constructs the AST for the source it's analysing. Doesn't need to special case anything to my knowledge. It's a dynamic analysis tool whereas pylance appears to be a static analysis tool. The tradeoff is performance versus correctness, as can be seen here.
I really think module six should be "mounted" somehow and the message not be displayed. It is a very used module. The funny thing is that the code complete finds the six.moves in the import.
Code-complete works because pylance bundles the stubs for six.moves from typeshed.
Perhaps pylance should just suppress reportMissingModuleSource for six.moves and sub-modules of it when six itself is found, as a known "implemented via sys.meta_path" case?
for now you can use # pyright: ignore on that line
Import "six.moves" could not be resolved from sourcePylancereportMissingModuleSource (module) moves
@mrkguruin I can confirm this error as well. But it is a different error from this issue. Can you please open a new issue?