pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

six.moves marked as missing module source

Open DylanYoung opened this issue 4 years ago • 7 comments

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

DylanYoung avatar May 26 '21 02:05 DylanYoung

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.

jakebailey avatar May 26 '21 03:05 jakebailey

Yeah; pylint can find it because it actually constructs the AST. Tricky for static analysis that's for sure.

DylanYoung avatar May 30 '21 05:05 DylanYoung

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.

jakebailey avatar Jun 01 '21 19:06 jakebailey

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.

DylanYoung avatar Jun 06 '21 20:06 DylanYoung

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.

wesleybl avatar Nov 01 '21 20:11 wesleybl

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?

TBBle avatar Nov 22 '21 10:11 TBBle

for now you can use # pyright: ignore on that line

bschnurr avatar Jun 10 '22 16:06 bschnurr

Import "six.moves" could not be resolved from sourcePylancereportMissingModuleSource (module) moves

mrkguruin avatar Jun 23 '23 10:06 mrkguruin

@mrkguruin I can confirm this error as well. But it is a different error from this issue. Can you please open a new issue?

wesleybl avatar Jun 23 '23 12:06 wesleybl