summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2020-05-02 12:21:20 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2020-05-02 12:42:28 +0200
commit54ce3bae10ce545a9f98272bba45e122e7ebaffa (patch)
tree5d716a4902a9667a6dddd02aed6c725724d68848
parent56495fdf6656ce5824f235a30294c1a76d10dcb5 (diff)
downloadpylint-git-54ce3bae10ce545a9f98272bba45e122e7ebaffa.tar.gz
Allow package files to be properly discovered with multiple jobs
Close #3524
-rw-r--r--ChangeLog4
-rw-r--r--pylint/utils/utils.py9
-rw-r--r--tests/test_self.py31
3 files changed, 40 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 706f040fe..9740612d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,10 @@ Release date: TBA
Close #3563
+* Allow package files to be properly discovered with multiple jobs
+
+ Close #3524
+
What's New in Pylint 2.5.0?
===========================
diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py
index 6febac19a..fd0c49355 100644
--- a/pylint/utils/utils.py
+++ b/pylint/utils/utils.py
@@ -104,12 +104,12 @@ def _basename_in_blacklist_re(base_name, black_list_re):
return False
-def _modpath_from_file(filename, is_namespace):
+def _modpath_from_file(filename, is_namespace, path=None):
def _is_package_cb(path, parts):
return modutils.check_modpath_has_init(path, parts) or is_namespace
return modutils.modpath_from_file_with_callback(
- filename, is_package_cb=_is_package_cb
+ filename, path=path, is_package_cb=_is_package_cb
)
@@ -200,7 +200,6 @@ def expand_modules(files_or_modules, black_list, black_list_re):
not (modname.endswith(".__init__") or modname == "__init__")
and os.path.basename(filepath) == "__init__.py"
)
-
if has_init or is_namespace or is_directory:
for subfilepath in modutils.get_module_files(
os.path.dirname(filepath), black_list, list_all=is_namespace
@@ -212,7 +211,9 @@ def expand_modules(files_or_modules, black_list, black_list_re):
):
continue
- modpath = _modpath_from_file(subfilepath, is_namespace)
+ modpath = _modpath_from_file(
+ subfilepath, is_namespace, path=additional_search_path
+ )
submodname = ".".join(modpath)
result.append(
{
diff --git a/tests/test_self.py b/tests/test_self.py
index f892224bb..296d93e74 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -732,3 +732,34 @@ class TestRunTC:
],
cwd=str(tmpdir),
)
+
+ def test_allow_import_of_files_found_in_modules_during_parallel_check(self, tmpdir):
+ test_directory = tmpdir / "test_directory"
+ test_directory.mkdir()
+ spam_module = test_directory / "spam.py"
+ spam_module.write("'Empty'")
+
+ init_module = test_directory / "__init__.py"
+ init_module.write("'Empty'")
+
+ # For multiple jobs we could not find the `spam.py` file.
+ with tmpdir.as_cwd():
+ self._runtest(
+ [
+ "-j2",
+ "--disable=missing-docstring, missing-final-newline",
+ "test_directory",
+ ],
+ code=0,
+ )
+
+ # A single job should be fine as well
+ with tmpdir.as_cwd():
+ self._runtest(
+ [
+ "-j1",
+ "--disable=missing-docstring, missing-final-newline",
+ "test_directory",
+ ],
+ code=0,
+ )