diff --git a/doc/whatsnew/fragments/10669.bugfix b/doc/whatsnew/fragments/10669.bugfix new file mode 100644 index 0000000000..035d3389d8 --- /dev/null +++ b/doc/whatsnew/fragments/10669.bugfix @@ -0,0 +1,3 @@ +Make 'ignore' option work as expected again. + +Closes #10669 diff --git a/pylint/lint/expand_modules.py b/pylint/lint/expand_modules.py index 0116c9bb7a..d51af24f60 100644 --- a/pylint/lint/expand_modules.py +++ b/pylint/lint/expand_modules.py @@ -150,7 +150,7 @@ def expand_modules( ) if has_init or is_namespace or is_directory: for subfilepath in modutils.get_module_files( - os.path.dirname(filepath) or ".", [], list_all=is_namespace + os.path.dirname(filepath) or ".", ignore_list, list_all=is_namespace ): subfilepath = os.path.normpath(subfilepath) if filepath == subfilepath: diff --git a/tests/lint/unittest_expand_modules.py b/tests/lint/unittest_expand_modules.py index 054687d0ab..5b3a7ddbbe 100644 --- a/tests/lint/unittest_expand_modules.py +++ b/tests/lint/unittest_expand_modules.py @@ -326,3 +326,23 @@ def test_expand_modules_with_ignore( ) assert {k: v for k, v in modules.items() if not v["isignored"]} == expected assert not errors + + @set_config(ignore=["test"]) + def test_expand_modules_with_ignore_list(self) -> None: + """Test expand_modules with a non-default value of ignore.""" + ignore_list: list[str] = self.linter.config.ignore + ignore_list_re = [re.compile("^\\.#")] + path = Path(__file__).parent.parent / "regrtest_data" / "ignore_option_10669" + modules, errors = expand_modules( + [str(path)], + [], + ignore_list, + ignore_list_re, + [], + ) + expected_keys = { + str(path / "__init__.py"), + str(path / "main.py"), + } + assert {k for k, v in modules.items() if not v["isignored"]} == expected_keys + assert not errors diff --git a/tests/regrtest_data/ignore_option_10669/__init__.py b/tests/regrtest_data/ignore_option_10669/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/regrtest_data/ignore_option_10669/main.py b/tests/regrtest_data/ignore_option_10669/main.py new file mode 100644 index 0000000000..a83ef2e8af --- /dev/null +++ b/tests/regrtest_data/ignore_option_10669/main.py @@ -0,0 +1,3 @@ +# pylint: disable=too-few-public-methods,missing-docstring +class A: + pass diff --git a/tests/regrtest_data/ignore_option_10669/test/__init__.py b/tests/regrtest_data/ignore_option_10669/test/__init__.py new file mode 100644 index 0000000000..268eb0f2d8 --- /dev/null +++ b/tests/regrtest_data/ignore_option_10669/test/__init__.py @@ -0,0 +1,4 @@ + +class i: + """many issues here""" + pass