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

Add ignore-paths to match against the full path #3266

Closed
wants to merge 1 commit into from

Conversation

bernardn
Copy link
Contributor

@bernardn bernardn commented Nov 21, 2019

Steps

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature or an important bug fix, add a What's New entry in doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Description

Add ignore-paths configuration directive. Checks against full file path.

Type of Changes

Type
βœ“ πŸ› Bug fix

Related Issue

Closes #2541

@bernardn bernardn force-pushed the issue/2541 branch 4 times, most recently from d574e15 to 2afb4d6 Compare November 21, 2019 12:58
@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 89.83% when pulling 2afb4d6 on bernardn:issue/2541 into 114298d on PyCQA:master.

@coveralls
Copy link

coveralls commented Nov 21, 2019

Coverage Status

Coverage decreased (-0.01%) to 90.68% when pulling f50ff61 on bernardn:issue/2541 into b0824e9 on PyCQA:master.

Copy link
Contributor

@PCManticore PCManticore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bernardn Thank you for sending the PR over! Overall it looks great, I just have a minor concern over the .match() behaviour which seems backwards incompatible to me.

:param list black_list_re: A collection of regex patterns to match against.
Successful matches are blacklisted.

:returns: `True` if the basename is blacklisted, `False` otherwise.
:rtype: bool
"""
for file_pattern in black_list_re:
if file_pattern.match(base_name):
if file_pattern.match(path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is a backwards incompatible change. Users that currently rely on ignore-patterns will suddenly see warnings from files they previously ignored. Given a full match might be too much, we might use .search here instead.
We should add a test for that to make sure what patterns that assumed this works on the basename will still filter out the corresponding files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PCManticore Thank you for your constructive comment. .search would indeed decrease the number of cases where backward-incompatibility occurs, but won't completely eliminate them, particularly when the tree structure presents repeating patterns, e.g., with ignore-patterns=foo:

whatever/foo/bar.py
whatever/foo/foo-a.py
whatever/foo/foo-b.py

The current implementation would lint bar.py, while this PR with .match or .search would ignore it

I'm afraid that to be fully backward compatible without anyone having to rewrite its ignore-patterns configuration directive, we'd have to implement a new one, such as ignore-path-patterns, what I can do.

What do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, kind reminder on this old PR.
Personally I find new separate option safer and more flexible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can update it, but would prefer to have @PCManticore thoughts before doing it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bernardn Sorry for letting this fall through the cracks. Here are my thoughts:

  • I think we should be backwards compatible to mess as little with users configuration as possible. Let's go with a new ignore-paths option, which will support regexes.
  • This will bring the choice for ignoring files or directories to three: ignore-paths, ignore and ignore-patterns. Once we have the first, we can start deprecating the other two, so we could remove them in pylint 3.0. We'll emit deprecation warnings when detecting their usage.
  • Let's throw an error if these three are used together. e.g. detect if ignore-paths is used with ignore-patterns and simply throw a new error from pylint.exceptions that this behaviour is not supported.

Let me know if that makes sense to you as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PCManticore This makes perfect sense to me as well, thank you! I'm going to implement this in the upcoming days.

pylint/utils/utils.py Outdated Show resolved Hide resolved
@alexchandel
Copy link

@bernardn Could you rebase your PR to resolve the conflicts?

@bernardn bernardn force-pushed the issue/2541 branch 4 times, most recently from 683c042 to 95a8b51 Compare July 13, 2020 10:52
List of regex matching against the full path

Close pylint-dev#2541
@bernardn bernardn changed the title ignore-patterns match against the full path instead of basename Add ignore-paths to match against the full path Jul 13, 2020
@hippo91
Copy link
Contributor

hippo91 commented Sep 19, 2020

@PCManticore did you approve this PR?
If yes, i'll will try to merge it to master.
Thanks in advance

@sanjayatn
Copy link

When is this PR getting merged to master?

@brycepg brycepg self-assigned this Oct 20, 2020
@brycepg
Copy link
Contributor

brycepg commented Oct 20, 2020

@sanjayatn I'll do a review of this in the coming weeks and solve the conflicts

@Zephor5
Copy link

Zephor5 commented Feb 5, 2021

any progress ? @brycepg

@brycepg brycepg removed their assignment Feb 7, 2021
@Pierre-Sassoulas Pierre-Sassoulas added Help wanted πŸ™ Outside help would be appreciated, good for new contributors Waiting on author Indicate that maintainers are waiting for a message of the author Enhancement ✨ Improvement to a component labels Mar 30, 2021
@Pierre-Sassoulas
Copy link
Member

Closed in favor of #4516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Help wanted πŸ™ Outside help would be appreciated, good for new contributors Waiting on author Indicate that maintainers are waiting for a message of the author Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ignore-patterns does not skip non-top-level directories.