diff --git a/doc/whatsnew/fragments/1667.bugfix b/doc/whatsnew/fragments/1667.bugfix new file mode 100644 index 0000000000..f4e3eeec5c --- /dev/null +++ b/doc/whatsnew/fragments/1667.bugfix @@ -0,0 +1,3 @@ +Fix a failure to lint packages with ``__init__.py`` contained in directories lacking ``__init__.py``. + +Closes #1667 diff --git a/tests/lint/unittest_lint.py b/tests/lint/unittest_lint.py index 7db8f47bd1..c9407bbc64 100644 --- a/tests/lint/unittest_lint.py +++ b/tests/lint/unittest_lint.py @@ -933,3 +933,12 @@ def test_import_sibling_module_from_namespace(initialized_linter: PyLinter) -> N with fix_import_path([tmpdir]): linter.check(["submodule2.py"]) assert not linter.stats.by_msg + + +def test_lint_namespace_package_under_dir(initialized_linter: PyLinter) -> None: + """Regression test for https://github.com/PyCQA/pylint/issues/1667""" + linter = initialized_linter + with tempdir(): + create_files(["outer/namespace/__init__.py", "outer/namespace/module.py"]) + linter.check(["outer.namespace"]) + assert not linter.stats.by_msg