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

Linters run on files that should be excluded based on configuration #3396

Closed
kbattocchi opened this issue Nov 19, 2018 · 2 comments
Closed
Assignees

Comments

@kbattocchi
Copy link
Member

Issue Type: Feature Request

Linters have ways of specifying which files to run on (e.g. pycodestyle provides a --filename argument which can be specified at the command line or in a setup.cfg file; pydocstyle has a similar --match argument). However, when these tools are explicitly run against a specific file (instead of discovering files themselves), these arguments are ignored, and it seems that this is how VS Code invokes the linters.

Failing to honor these arguments adds noise to the linting results in VS Code. For example, pydocstyle will flag missing documentation in files with names starting with "test_", even though these are excluded by default when pydocstyle is run from the command line - this can easily add hundreds of unwanted "problems" to the Problems list.

To avoid this, there should be some mechanism to honor the file inclusion/exclusion configuration that each linter uses.

Extension version: 2018.10.1
VS Code version: Code 1.28.2 (7f3ce96ff4729c91352ae6def877e59c561f4850, 2018-10-17T00:23:51.859Z)
OS version: Windows_NT x64 10.0.17763

@brettcannon brettcannon added feature-request Request for new features or functionality area-linting needs decision labels Nov 19, 2018
@DonJayamanne DonJayamanne self-assigned this Nov 19, 2018
@DonJayamanne
Copy link

It is documented here https://code.visualstudio.com/docs/python/settings-reference#_linting-settings

  • The solution is as follows (add the following setting into your settings.json):
"python.linting.ignorePatterns": [
        ".vscode/*.py",
        "**/site-packages/**/*.py"
    ]

@DonJayamanne DonJayamanne removed needs decision feature-request Request for new features or functionality labels Nov 19, 2018
@kbattocchi
Copy link
Member Author

@DonJayamanne That doesn't quite meet my needs; perhaps I should elaborate:

  1. I have multiple linters enabled (pep8/pycodestyle and pydocstyle).
  2. As per their defaults, I want pycodestyle to run on all .py files (even tests), but I only want pydocstyle to run on non-test .py files (I want tests to be written up to normal standards, but they don't need public documentation).
  3. We have a CI setup that runs these tools and verifies that they pass before accepting the build. This uses the setup.cfg from my main directory to read the configuration of the linting tools.
  4. I would like VS Code's "Problems" to be as aligned with the CI loop as possible. In both cases, nearly all configuration settings are read from the setup.cfg file and applied correctly; however, since the linters are run on a per-file basis the file matching rules are not applied in the same way.

With the current tooling, I can either choose to add an entry to the python.linting.ignorePatterns to exclude tests (in which case build-breaking pep8 style violations in test code will not be flagged as problems) or I can leave the setting as is (in which case I have hundreds of fictitious "problems" because our tests are not documented).

@lock lock bot locked as resolved and limited conversation to collaborators Dec 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants