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

ignore-paths: normalize path to PosixPath #5194

Closed
Spectre5 opened this issue Oct 21, 2021 · 1 comment · Fixed by #5201
Closed

ignore-paths: normalize path to PosixPath #5194

Spectre5 opened this issue Oct 21, 2021 · 1 comment · Fixed by #5201
Assignees
Labels
Enhancement ✨ Improvement to a component

Comments

@Spectre5
Copy link

Current problem

In a project of mine, there is an entire directory, "dummy", that I want to exclude running pylint in. I've added the directory name to the "ignore" option and it works great when used from the command line.

# Files or directories to be skipped. They should be base names, not paths.
ignore = [
  'dummy',
]

However, when using vscode, the full path is provided. It calls pylint like this:

~\Documents\<snip>\.venv\Scripts\python.exe -m pylint --msg-template='{line},{column},{category},{symbol}:{msg} --reports=n --output-format=text ~\Documents\<snip>\dummy\file.py

In this case, the ignore rule doesn't work and vscode still reports errors. So I decided to switch to the "ignore-paths" option. The following works:

# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths.
ignore-paths = [
  '.*/dummy/.*$',
  '.*\\dummy\\.*$',
]

However, I need to duplciate each path, onces for Linux (/ as path separator) and the second for Windows (\ as path separator). Would it be possible to normalize the paths (could use pathlib PosixPath) so that just the linux one would work on both systems? Note also that vscode passes the full path, so starting the regex with a ^, like '^dummy/.*$', won't work.

Desired solution

I'd like to be able to define the path only once in the "ignore-paths" settings. Even better would be to respect the "ignore" setting even for a path provided with the full path (just as if it was run from the command line).

# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths.
ignore-paths = [
  '.*/dummy/.*$',
]

Additional context

No response

@Spectre5 Spectre5 added Enhancement ✨ Improvement to a component Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Oct 21, 2021
@Pierre-Sassoulas Pierre-Sassoulas removed the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Oct 21, 2021
@Pierre-Sassoulas
Copy link
Member

Thank you for opening the issue, this seems like a sensible thing to do.

@DanielNoord DanielNoord self-assigned this Oct 21, 2021
DanielNoord added a commit to DanielNoord/pylint that referenced this issue Oct 21, 2021
DanielNoord added a commit to DanielNoord/pylint that referenced this issue Oct 23, 2021
DanielNoord added a commit that referenced this issue Oct 24, 2021
Closes #5194

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants