Skip to content

Commit db9fb46

Browse files
shifqupylint-backport[bot]
authored andcommitted
fix(expand_modules): pass ignore_list to modutils.get_module_files (#10720)
(cherry picked from commit cd2839d)
1 parent 755f2d0 commit db9fb46

File tree

6 files changed

+31
-1
lines changed

6 files changed

+31
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Make 'ignore' option work as expected again.
2+
3+
Closes #10669

pylint/lint/expand_modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def expand_modules(
150150
)
151151
if has_init or is_namespace or is_directory:
152152
for subfilepath in modutils.get_module_files(
153-
os.path.dirname(filepath) or ".", [], list_all=is_namespace
153+
os.path.dirname(filepath) or ".", ignore_list, list_all=is_namespace
154154
):
155155
subfilepath = os.path.normpath(subfilepath)
156156
if filepath == subfilepath:

tests/lint/unittest_expand_modules.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,23 @@ def test_expand_modules_with_ignore(
326326
)
327327
assert {k: v for k, v in modules.items() if not v["isignored"]} == expected
328328
assert not errors
329+
330+
@set_config(ignore=["test"])
331+
def test_expand_modules_with_ignore_list(self) -> None:
332+
"""Test expand_modules with a non-default value of ignore."""
333+
ignore_list: list[str] = self.linter.config.ignore
334+
ignore_list_re = [re.compile("^\\.#")]
335+
path = Path(__file__).parent.parent / "regrtest_data" / "ignore_option_10669"
336+
modules, errors = expand_modules(
337+
[str(path)],
338+
[],
339+
ignore_list,
340+
ignore_list_re,
341+
[],
342+
)
343+
expected_keys = {
344+
str(path / "__init__.py"),
345+
str(path / "main.py"),
346+
}
347+
assert {k for k, v in modules.items() if not v["isignored"]} == expected_keys
348+
assert not errors

tests/regrtest_data/ignore_option_10669/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# pylint: disable=too-few-public-methods,missing-docstring
2+
class A:
3+
pass
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
class i:
3+
"""many issues here"""
4+
pass

0 commit comments

Comments
 (0)