pylance-release
pylance-release copied to clipboard
searchImport not finding modules
I dont have enough information yet to provide a reproducible example, but to first describe the issue:
I'm observing that VSCode quick-fix and autoimport functionality are unable to find symbols in a specific python package installed as a dependency in a virtualenv for the project I'm working on. However, once I manually import the module, vscode recognizes it / is able to jump to the source / etc (in other words, once it's told to import the module, everything works as expected). This has only recently become an issue afaik, but is still working for other installed python packages.
When prompted to "search for additional import matches", it is able to find the root name of the package in question but no submodules/symbols below that.
Is it possible to print the search paths that searchImports is using to try to debug further to provide more information here? Currently have pylance/python log levels set to trace but nothing interesting is popping up.
Environment data
- Python 3.11
- vscode Version: 1.88.1
- vscode-python: v2024.5.11021008
- vscode-pylance: v2024.4.1
you need to use python.analysis.packageIndexDepths. see https://github.com/microsoft/pylance-release/blob/main/README.md#settings-and-customization for more detail.
due to perf reason, we only index top level symbols by default.
Just remember, the deeper you go (more submodules), the bigger the performance hit you get (more symbols to show, more files to scan/index). Also, take a look at other option and command around persisting indices and clearing persisted indices.
I do already have that variable set:
"python.analysis.packageIndexDepths": [
{
"name": "thePackageName",
"depth": 50,
"includeAllSymbols": true,
}
],
As well as these other settings:
"python.analysis.autoImportCompletions": true,
"python.analysis.userFileIndexingLimit": -1,
"python.analysis.persistAllIndices": true,
I see. then if you can share repro steps or at least trace log, it would give us some data to take a look.
repro step would be best, if not, the log and probably where your package is installed and every setting you have if it is not included in the log already.
This issue has been closed automatically because it needs more information and has not had recent activity. If the issue still persists, please reopen with the information requested. Thanks.
I was just about to post something about this
Search for additional import matches
-thing because it also yielded absolutely nothing for me! Initially I was unable to get import completions on super regularly used packages and this option is offered in the Quick-Fix menu.
But now I also looked into the suggested python.analysis.packageIndexDepths for my settings.json and Voilà!! It works!
There should be something like "missing something", "add this to packageIndexDepths" in the Quick-Fixes.
I still got problems with sub.sub.elements of packages tho. No matter how I turn the depth :/
@ewerybody can you open a new issue describing your issue? then we can take a look.
Yea I'd like to take some time to make a minimal example. But I don't have that time at the moment. I'm sorry.