-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Improve configuration for search paths #6544
Comments
Thank you for the suggestion! We have marked this issue as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes your idea gets to help us make our decision. |
@karthiknadig correct me if I'm wrong but I believe this may be possible now with the following extensions and settings:
|
Pylint extension automatically adds paths from |
Awesome, thanks! I think this can be closed now but let us know if you still have any issues and we can reopen :) |
Parts of this question was already answered several times, so be patient when reading. :)
Our usual workspace structure is:
Nothing unusual here.
Than, we have another folder with common python modules in remote location - this location is added by modules (inserting to
sys.path
). I will call this location remoteDir.When running main.py from VS Code, we specify launch configuration with cwd changed to rootDir/sources. It runs OK, files from common and remoteDir are accessible (since
sys.path
is manually modified).To implement autocomplete (either Intellisense Python Language Server or JEDI) and Pylint, this directories are not seen by default - .vscode-workspace file is not in sources folder. I am aware of PYTHONPATH variable in .env file - I added sources and remoteDir to PYTHONPATH variable and VS Code autocomplete and pylint works as expected.
The problem is that this PYTHONPATH variable affects the code and is bound to this IDE, which I don't like - one could easily develop code with VS Code (which has specified PYTHONPATH) and forget to handle
sys.path
, not knowing that the code now can't be executed without this IDE and it's .env settings.Example: A newbie come to our department, take prepared VS Code workspace and create a new module in common folder, which must be executed also in standalone mode. In this module, he wants to use functions from remoteDir. Since PYTHONPATH is already set in .env, he doesn't know that he actually have to manually handle
sys.path
- autocomplete and pylint just works out of the box. Also, using VS Code, he can run main.py or his new script without problems. But, if he (or someone else) run this script from a command line:cd ./sources/common; python hisCommonFile.py
, this will fail. Why - because nothing specify PYTHONPATH variable, and he doesn't havesys.path
handled properly.The question is: how to properly configure folder paths for autocomplete and pylint in VS Code, that wouldn't have any effect on how code is executed? I don't expect autocomplete and linter would interactively resolve modified
sys.path
- seems like there should be something similar to PYTHONPATH, but would be only applied to autocomplete/pylint VS Code tasks, not launch configurations.Just for a clarification: I know this might be a silly example. Our case is a little more complex than described above, but the problem is somewhat simillar - I miss
includeFolders=[]
in both autocomplete and pylint settings section, or better, some common settings.autocomplete.extraPaths
only solve problems for autocomplete (if it is working, last time I was checking It didn't work properly), not pylint - again, duplicated settings.The text was updated successfully, but these errors were encountered: