-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get imports generated across project roots? #1587
Comments
It sounds like you're describing #1055. If you haven't already imported the file from your workspace (either directly or via some other file), then we won't have analyzed the file, so won't suggest anything. The indexer is currently disabled for user code except in the case of quick fixes, which is #1055, so having the file already be analyzed is what makes it work. |
Can you try opening that file you want auto-imports from, then see if the auto import works in the other file? |
Did you already have the opportunity to have a closer look into this problem? |
I am having the same issue also |
@ThiefMaster assuming you have indexing option set "python.analysis.indexing": true in settings.json, if you open "vscode-python-roots-test" as root folder, you will see code actions for add imports. we currently don't show symbols defined in user files in completion to reduce number of items in the completion. in case you are using multi root workspace with pip install -e, we only supports top level symbols by default in completion. you will need to use our hidden options in settings.json to make us to discover symbols in sub modules. see this #2312 (comment) |
I also opened this issue to improve multi root workspace UX - #2601 |
Environment data
Expected behavior
If I write
main_function
ina/test_plugin_a/__init__.py
and ask for autocompletion or import generation, I expect this function to be suggested withfrom main_project import main_function
.Actual behavior
It doesn't happen. However, Pylance clearly understands the import location, because if I manually add the import, "Go to definition" works fine. "Go to references" on the other hand does not find a reference to that function in the plugin root.
Logs
Python Language Server Log
and the log from when I use ctrl-period to attempt to generate the import via code actions:
from ctrl-space for autocompletion:
Code Snippet / Additional information
Here's a Git repo with my minimal example project where I tested it: https://github.com/ThiefMaster/vscode-python-roots-test
As you can see in the workspace settings, I already tried using the
python.*.extraPaths
options, but to no avail. I also installed both of the packages in the Python virtualenv viapip install -e ...
in case it made a difference - but nope.In my main project I have indexing enabled btw, but it doesn't seem to make a difference.
The text was updated successfully, but these errors were encountered: