Intro:
In PyCharm, there is ability to open several Git repositories and specify dependencies between them, so that you can import packages from one repository into another repository and use methods from them with IntelliSense (auto-completion - when you can see methods for a given object).
In Visual Studio Code, there is ability to add several git repositories to one workspace, but auto completion for object/methods works only in the current repository:
Say, I have abcd.py in Repo 1 and fgh.py in Repo 2, and I import a class from fgh.py to abcd.py. In this scheme, when I edit abcd.py, auto completion works only for objects/methods in classes from Repo 1, not for objects/methods in a class from Repo 2.
Question:
Is it somehow possible to configure Visual Studio Code in such a way that auto completion works in the case described above - like it works in PyCharm?
Thank you.
I googled it, but didn't find any answer.
There are a few approaches you could take to achieve this.
You can modify the language server settings to include the path where fgh.py
is found.
In VS Code's settings, add its path to the python.analysis.include
option.
This is similar to installing a package normally, but the location of it is set to the original location, rather than creating a copy of it (meaning edits are seen in any code using the package). See the documentation here.
pip install -e /path/to/the/library
This should give VS Code enough information to allow it to provide intellisense, and is editor-independent (so would work in all projects).
For example, if your directory structure is
/my/project/
lib_1
fgh.py
lib_2
abcd.py
You could potentially open up /my/project
and VS Code should hopefully spot the dependencies.