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

regex for ignoring hidden directories doesn't work as expected #7089

Closed
tbennett0 opened this issue Jun 29, 2022 · 7 comments
Closed

regex for ignoring hidden directories doesn't work as expected #7089

tbennett0 opened this issue Jun 29, 2022 · 7 comments
Labels
Bug 🪲 Duplicate 🐫 Duplicate of an already existing issue Regression

Comments

@tbennett0
Copy link
Contributor

tbennett0 commented Jun 29, 2022

Bug description

In running pylint --recursive y . to ignore hidden directories using 2.14.4, I discovered the following pattern works:

[tool.pylint.MASTER]
ignore-paths = [
  "^.local/.*$"
]

but this one doesn't:

[tool.pylint.MASTER]
ignore-paths = [
  "^\\.local/.*$"
]

I would expect that the regex would see . as any character, so it matches the first, but explicitly using an escaped period that should also match doesn't cause that path to be ignored.

Configuration

% cat .local/test.py
import blam

Command used

% pylint --recursive=y .

Pylint output

************* Module test
.local/test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
.local/test.py:1:0: E0401: Unable to import 'blam' (import-error)
.local/test.py:1:0: W0611: Unused import blam (unused-import)

Expected behavior

No output on both examples.

Pylint version

pylint 2.14.4
astroid 2.11.6
Python 3.9.12 (main, Jun 27 2022, 13:42:07)
[Clang 13.1.6 (clang-1316.0.21.2.5)]

OS / Environment

No response

Additional dependencies

No response

@tbennett0 tbennett0 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jun 29, 2022
@tbennett0 tbennett0 changed the title regex for pylint ignoring hidden directories doesn't work as expected regex for ignoring hidden directories doesn't work as expected Jun 29, 2022
@tbennett0
Copy link
Contributor Author

@matusvalo this is possibly related to #6964. Thanks!

@matusvalo
Copy link
Collaborator

@tbennett0 could you verify the issue with the main branch whether it fixes the issue?

@DanielNoord
Copy link
Collaborator

@matusvalo 2.14.4 was just released, which included your fix for #6964. So this seems to be a regression after that fix was applied.

@matusvalo
Copy link
Collaborator

OK I have misread the issue. So I need to fix the fix of the fix :-/. OK I am sorry for that. Doing recursive linting seems to be not so trivial as looked in the first place :-/

@Pierre-Sassoulas Pierre-Sassoulas added Regression Needs PR This issue is accepted, sufficiently specified and now needs an implementation Bug 🪲 and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jun 29, 2022
@matusvalo
Copy link
Collaborator

matusvalo commented Jun 29, 2022

OK, I have investigated issue. It seems that the issue has root cause in parameter parsing rather then in recursive logic:

  1. fix of False positive no-value-for-parameter for Qt methods #6464 is already fixing first case ("^.local/.*$") - can be easily checked, 2.14.3 version of pylint ignores the regex
  2. For the case "^\\.local/.*$", I put breakpoint in the line https://github.com/PyCQA/pylint/blob/018176d48b5608bdbc2ef9a8d09b0cae7a83da33/pylint/lint/expand_modules.py#L57 which gives me following:
(Pdb) p element
'.local/test.py'
(Pdb) p ignore_list_paths_re
[re.compile('^\\\\.local\\\\.*$|^/.local/.*$')]
(Pdb) ignore_list_paths_re[0].match(element)

ignore_list_paths_re is not matched due \\\\ part which does not match the input. The cause of different patterns seems following portion of the code:
https://github.com/PyCQA/pylint/blob/018176d48b5608bdbc2ef9a8d09b0cae7a83da33/pylint/config/argument.py#L110-L121

It seems like managing path delimiter in windows, but I am not 100% confident with this part of pylint. @DanielNoord could you give me a hint?

@DanielNoord
Copy link
Collaborator

Ah yeah. This is a duplicate of #5398.

@matusvalo
Copy link
Collaborator

OK so I am closing it as duplicate.

@matusvalo matusvalo closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2022
@Pierre-Sassoulas Pierre-Sassoulas added Duplicate 🐫 Duplicate of an already existing issue and removed Needs PR This issue is accepted, sufficiently specified and now needs an implementation labels Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Duplicate 🐫 Duplicate of an already existing issue Regression
Projects
None yet
Development

No branches or pull requests

4 participants