Language Server version: 2020.8.1
When provided path to folder containing .pyc files in setting python.analysis.extraPaths intellisense should provide list of methods for modules in that folder.
Intellisense isn't able to resolve compiled modules (.pyc). It shows error -> Import "hello" could not be resolvedPylance (reportMissingImports). On based of reading else where I was under the impression that pylance can scrap info from .pycs to provide intellisense. Please correct me if I am wrong. I am using following command to compile
python.exe -m compileall -b ..libraryhello.py
I am attaching pseudo code intellisesne_pyc.zip. This folder contains workspace folder and library folder. The code in workspace folder imports module in library folder that is compiled. I hope this helps.
Pylance cannot read info from compiled modules, no. Compiled code currently requires a stub to work, and we will not try and execute the compile code to learn of its contents. Note that MPLS didn't do this either for user code, but would for libraries.
Pylance does not attempt to extract type information from binary files. The interface to native files needs to be described with a type stub ("pyi") file. Many library authors are now providing such stubs with the latest versions of their packages, so please check that you have the latest version installed. If the latest version of the library is missing the stub, I encourage you to submit a request to the library author.
Thank you for the quick reply. I am the library author and was experimenting with VS code configuration as if I am the user of library. We are already generating pyi files for pyds. We are using pybind11 tools to do that. I was expecting pyc to work out of the box. I will look into tools to generate pyi file. Please let me know if you have any recommendations.
pyc files isn't advisable as they don't really contain the right kind of info. You may have a better experience writing the pyi files directly (this is what is being done in numpy, torch, etc), but I'm not sure what the size of your project is.Pylance cannot read info from compiled modules, no. Compiled code currently requires a stub to work, and we will not try and execute the compile code to learn of its contents. Note that MPLS didn't do this either for user code, but would for libraries.
@jakebailey I got wrong impression because this comment https://github.com/microsoft/python-language-server/issues/1081#issuecomment-498068163. When I read that comment again I think it was in context of Jedi LS. Probably it works with Jedi?
As far as I know, Jedi does not enable its "scraper" mode by default, and requires user configuration to allow it.
Investigating solutions for compiled modules
a new repo for stub is available at python-type-stubs. This is open for contributions. Snapshots from here will be periodically shipped with Pylance.
This is the place to add stubs for compiled modules. As mentioned above, Pylance will not scrape compiled modules.