Skip to content

Expose a setting to change the working directory of linters #15170

@matthewshirley

Description

@matthewshirley

Currently, a linter will execute at the workspace root. In some cases, a user may want to have the linter execute in a different directory. There should be a setting exposed to allow a user to customize the current working directory of the linter, similar to testing.

Scenario: pylint-django

Consider a Django application using pylint with pylint-django. This requires pylint to receive an argument that points to the Django settings module. However, there might be a case where the settings module is not accessible from the root and cannot be imported causing the plugin to fail. Example:

File Structure

  • bin
  • docs
  • myapp
    • .pylintrc
    • src
      • __init__.py

Configuration

    "python.linting.enabled": true,
    "python.linting.pylintEnabled": true,
    "python.linting.pylintArgs": [
        "--load-plugins=pylint_django",
        "--django-settings-module=myapp.settings"
    ],

Result

error,django-not-configured:Django was not configured.

Requested Behaviour

The user should be able to set their working directory for linting.

    "python.linting.enabled": true,
    "python.linting.cwd": "${workspaceFolder}/myapp",
    "python.linting.pylintEnabled": true,
    "python.linting.pylintArgs": [
        "--load-plugins=pylint_django",
        "--django-settings-module=greenspace.settings"
    ],

Scenario: mypy

The above scenario applies to mypy and django-stubs.

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions