Skip to content

Commit c74493b

Browse files
matusvaloPierre-Sassoulaspre-commit-ci[bot]
authored
Normalize path before checking if path should be ignored (#7080)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent c603f0e commit c74493b

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

doc/whatsnew/2/2.14/full.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ What's New in Pylint 2.14.4?
55
----------------------------
66
Release date: TBA
77

8+
* Fixed an issue where scanning `.` directory recursively with ``--ignore-path=^path/to/dir`` is not
9+
ignoring the `path/to/dir` directory.
10+
11+
Closes #6964
12+
813
* Fixed regression that didn't allow quoted ``init-hooks`` in option files.
914

1015
Closes #7006

pylint/lint/expand_modules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def _is_ignored_file(
5252
ignore_list_re: list[Pattern[str]],
5353
ignore_list_paths_re: list[Pattern[str]],
5454
) -> bool:
55+
element = os.path.normpath(element)
5556
basename = os.path.basename(element)
5657
return (
5758
basename in ignore_list

tests/test_self.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,27 @@ def test_recursive_current_dir(self):
13301330
code=0,
13311331
)
13321332

1333+
def test_ignore_path_recursive_current_dir(self) -> None:
1334+
"""Tests that path is normalized before checked that is ignored. GitHub issue #6964"""
1335+
with _test_sys_path():
1336+
# pytest is including directory HERE/regrtest_data to sys.path which causes
1337+
# astroid to believe that directory is a package.
1338+
sys.path = [
1339+
path
1340+
for path in sys.path
1341+
if not os.path.basename(path) == "regrtest_data"
1342+
]
1343+
with _test_cwd():
1344+
os.chdir(join(HERE, "regrtest_data", "directory"))
1345+
self._runtest(
1346+
[
1347+
".",
1348+
"--recursive=y",
1349+
"--ignore-paths=^ignored_subdirectory/.*",
1350+
],
1351+
code=0,
1352+
)
1353+
13331354
def test_regression_recursive_current_dir(self):
13341355
with _test_sys_path():
13351356
# pytest is including directory HERE/regrtest_data to sys.path which causes

0 commit comments

Comments
 (0)