Skip to content
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

Closed
schperplata opened this issue Jul 11, 2019 · 4 comments
Closed

Improve configuration for search paths #6544

schperplata opened this issue Jul 11, 2019 · 4 comments
Labels
area-editor-* User-facing catch-all feature-request Request for new features or functionality

Comments

@schperplata
Copy link

schperplata commented Jul 11, 2019

Parts of this question was already answered several times, so be patient when reading. :)
Our usual workspace structure is:

rootDir/:
    - project.vscode-workspace
    - sources/:
        - main.py
        - someSrcFile.py
        - ...
        - common/:
            - commFileOne.py
            - ...

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.

<some remote location>
remoteDir/:
    - remoteModule.py
    - ...

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 have sys.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.

@schperplata schperplata added the triage-needed Needs assignment to the proper sub-team label Jul 11, 2019
@DonJayamanne DonJayamanne added needs decision feature-request Request for new features or functionality labels Jul 11, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jul 11, 2019
@brettcannon
Copy link
Member

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.

@luabud
Copy link
Member

luabud commented Dec 14, 2023

@karthiknadig correct me if I'm wrong but I believe this may be possible now with the following extensions and settings:

@karthiknadig
Copy link
Member

Pylint extension automatically adds paths from python.analysis.extraPaths to PYTHONPATH when running pylint.

@luabud
Copy link
Member

luabud commented Dec 14, 2023

Awesome, thanks!

I think this can be closed now but let us know if you still have any issues and we can reopen :)

@luabud luabud closed this as completed Dec 14, 2023
@github-actions github-actions bot removed the needs proposal Need to make some design decisions label Dec 14, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-editor-* User-facing catch-all feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

6 participants