Skip to content

Commit

Permalink
ignore-patterns match against the full path instead of basename
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernard Nauwelaerts committed Nov 21, 2019
1 parent 42c6fa2 commit f3093d7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,5 @@ contributors:
* Bastien Vallet: contributor

* Pek Chhan: contributor

* Bernard Nauwelaerts: contributor
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ What's New in Pylint 2.5.0?

Release date: TBA

* Fixed ``ignore-patterns`` behaviour. Defined patterns are matched against full file path instead of file base name.

Close #2541

* Add a --fail-under <score> flag, also configurable in a .pylintrc file. If the final score is more than the specified score, it's considered a success and pylint exits with exitcode 0. Otherwise, it's considered a failure and pylint exits with its current exitcode based on the messages issued.

Close #2242
Expand Down
2 changes: 2 additions & 0 deletions doc/whatsnew/2.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ separated list of regexes, that if a name matches will be always marked as a bla
* Mutable ``collections.*`` are now flagged as dangerous defaults.

* Add new --fail-under flag for setting the threshold for the score to fail overall tests. If the score is over the fail-under threshold, pylint will complete SystemExit with value 0 to indicate no errors.

* ``ignore-patterns`` now checked against the full file path instead of the file base name
2 changes: 1 addition & 1 deletion pylint/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from pylint.utils.ast_walker import ASTWalker
from pylint.utils.file_state import FileState
from pylint.utils.utils import (
_basename_in_blacklist_re,
_is_in_blacklist_re,
_check_csv,
_format_option_value,
_splitstrip,
Expand Down
8 changes: 4 additions & 4 deletions pylint/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ def tokenize_module(module):
return list(tokenize.tokenize(readline))


def _basename_in_blacklist_re(base_name, black_list_re):
def _is_in_blacklist_re(path, black_list_re):
"""Determines if the basename is matched in a regex blacklist
:param str base_name: The basename of the file
:param str path: The file path
: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):
return True
return False

Expand All @@ -125,7 +125,7 @@ def expand_modules(files_or_modules, black_list, black_list_re):
for something in files_or_modules:
if basename(something) in black_list:
continue
if _basename_in_blacklist_re(basename(something), black_list_re):
if _is_in_blacklist_re(something, black_list_re):
continue
if exists(something):
# this is a file or a directory
Expand Down

0 comments on commit f3093d7

Please sign in to comment.