From 716bcc4e0e8ea5a4d5ab4836c4042b816a5e64d0 Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Sat, 2 May 2020 14:04:46 +0200 Subject: [PATCH] Allow linting directories without `__init__.py` This was a regressin in 2.5. Close #3528 --- ChangeLog | 4 ++++ pylint/utils/utils.py | 2 +- tests/test_self.py | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b961ce4b0..fafae7a41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,10 @@ Release date: TBA Close #3524 +* Allow linting directories without `__init__.py` which was a regression in 2.5. + + Close #3528 + What's New in Pylint 2.5.0? =========================== diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py index fd0c49355..658316cf2 100644 --- a/pylint/utils/utils.py +++ b/pylint/utils/utils.py @@ -142,7 +142,7 @@ def expand_modules(files_or_modules, black_list, black_list_re): continue module_path = get_python_path(something) - additional_search_path = [module_path] + path + additional_search_path = [".", module_path] + path if os.path.exists(something): # this is a file or a directory try: diff --git a/tests/test_self.py b/tests/test_self.py index 296d93e74..d843efe40 100644 --- a/tests/test_self.py +++ b/tests/test_self.py @@ -763,3 +763,18 @@ class TestRunTC: ], code=0, ) + + def test_can_list_directories_without_dunder_init(self, tmpdir): + test_directory = tmpdir / "test_directory" + test_directory.mkdir() + spam_module = test_directory / "spam.py" + spam_module.write("'Empty'") + + with tmpdir.as_cwd(): + self._runtest( + [ + "--disable=missing-docstring, missing-final-newline", + "test_directory", + ], + code=0, + )