Skip to content

Commit e820200

Browse files
Normalize path before checking if path should be ignored (#7080)
Co-authored-by: Pierre Sassoulas <[email protected]>
1 parent c82d08c commit e820200

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

doc/whatsnew/2/2.14/full.rst

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Release date: TBA
99

1010
Closes #6950
1111

12+
* Fixed an issue where scanning `.` directory recursively with ``--ignore-path=^path/to/dir`` is not
13+
ignoring the `path/to/dir` directory.
14+
15+
Closes #6964
16+
1217
* Fixed regression that didn't allow quoted ``init-hooks`` in option files.
1318

1419
Closes #7006

pylint/lint/expand_modules.py

+1
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

+21
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)