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

pylint should handle python.linting.cwd settings #215

Closed
sevdog opened this issue Nov 9, 2022 · 2 comments · Fixed by #251
Closed

pylint should handle python.linting.cwd settings #215

sevdog opened this issue Nov 9, 2022 · 2 comments · Fixed by #251
Assignees
Labels
feature-request Request for new features or functionality info-needed Issue requires more information from poster needs community feedback

Comments

@sevdog
Copy link

sevdog commented Nov 9, 2022

In a multi-language project there could be a setup where the python source folder does not declare any __init__.py file and thus it is not a package from which imports can be performed.

workspace/
├─ django_project/
│  ├─ my_app/
│  ├─ project/
│  │  ├─ settings.py
│  │  ├─ __init__.py
│  ├─ manage.py
├─ other/

In this example, since the sole python part is under django_project then DJANGO_SETTINGS_MODULE is set as project.settings.
Thus if using pylint-django than in .pylintrc or via commandline I will use django-settings-module=project.settings.

But as of now this fails with a ModuleNotFoundError: No module named 'project' since server CWD is workspace, thus the python interpreter cannot see any package which is in the django_project folder.

If the server uses python.linting.cwd this setting could be used to adjust the CWD and thus enabling the interpreter to discover contained packages.

@github-actions github-actions bot added the triage-needed Issue is not triaged. label Nov 9, 2022
@karthiknadig
Copy link
Member

There are two ways to address this:

  1. Extension feature: Read the python.linting.cwd and use that as CWD when running pylint
  2. Using Multiroot workspaces: You could make use of multiroot workspaces and add django_project, other and workspace as three workspace folders. This does not require a change in how extension currently works and handled multiroot and this should work.

@karthiknadig karthiknadig added feature-request Request for new features or functionality info-needed Issue requires more information from poster needs community feedback and removed triage-needed Issue is not triaged. labels Jan 9, 2023
@sevdog
Copy link
Author

sevdog commented Jan 10, 2023

Hi @karthiknadig, the problem with multi-root workspace is that in the current root directory there are other configuration files which are required to run the whole setup (ie: a docker-compose.yml, and each inner directory is a service in this compose).

I was already using the old pylint integration in vscode-python. I was expecting this one to inherit configurations from that extension, or at least a "CWD" configuration (since the old one did provide one).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality info-needed Issue requires more information from poster needs community feedback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants