summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2020-06-18 09:08:50 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2020-06-20 12:15:52 +0200
commitda91a9ad743d145824f3966789bcb2dcaf5484db (patch)
treeaee193d9708aa4d2f5a4f5049051ff42b3f7d4be
parent4e2529cebbc0efc4f6bb54902fc9eadf9052f0a3 (diff)
downloadpylint-git-2.5.tar.gz
Fix a crash in parallel mode when the module's filepath is not set2.5
Close #3564
-rw-r--r--ChangeLog5
-rw-r--r--pylint/lint/check_parallel.py14
-rw-r--r--tests/regrtest_data/regression_missing_init_3564/subdirectory/file.py0
-rw-r--r--tests/test_self.py8
4 files changed, 23 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 3d0f8de51..c132b157a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
Pylint's ChangeLog
------------------
+
What's New in Pylint 2.5.4?
===========================
@@ -11,6 +12,10 @@ Release date: TBA
Close #3690
+* Fix a crash in parallel mode when the module's filepath is not set
+
+ Close #3564
+
What's New in Pylint 2.5.3?
===========================
diff --git a/pylint/lint/check_parallel.py b/pylint/lint/check_parallel.py
index 4f36f7f4a..201f1c878 100644
--- a/pylint/lint/check_parallel.py
+++ b/pylint/lint/check_parallel.py
@@ -71,6 +71,7 @@ def _worker_check_single_file(file_item):
msgs = [_get_new_args(m) for m in _worker_linter.reporter.messages]
return (
_worker_linter.current_name,
+ filepath,
_worker_linter.file_state.base_name,
msgs,
_worker_linter.stats,
@@ -98,11 +99,16 @@ def check_parallel(linter, jobs, files, arguments=None):
all_stats = []
- for module, base_name, messages, stats, msg_status in pool.imap_unordered(
- _worker_check_single_file, files
- ):
+ for (
+ module,
+ file_path,
+ base_name,
+ messages,
+ stats,
+ msg_status,
+ ) in pool.imap_unordered(_worker_check_single_file, files):
linter.file_state.base_name = base_name
- linter.set_current_module(module)
+ linter.set_current_module(module, file_path)
for msg in messages:
msg = Message(*msg)
linter.reporter.handle_message(msg)
diff --git a/tests/regrtest_data/regression_missing_init_3564/subdirectory/file.py b/tests/regrtest_data/regression_missing_init_3564/subdirectory/file.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/regrtest_data/regression_missing_init_3564/subdirectory/file.py
diff --git a/tests/test_self.py b/tests/test_self.py
index 6c27fd6cd..11399ab5c 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -783,3 +783,11 @@ class TestRunTC:
path = join(HERE, "regrtest_data", "unused_variable.py")
expected = "Your code has been rated at 7.50/10"
self._test_output([path, "--jobs=2", "-ry"], expected_output=expected)
+
+ def test_regression_parallel_mode_without_filepath(self):
+ # Test that parallel mode properly passes filepath
+ # https://github.com/PyCQA/pylint/issues/3564
+ path = join(
+ HERE, "regrtest_data", "regression_missing_init_3564", "subdirectory/"
+ )
+ self._test_output([path, "-j2"], expected_output="No such file or directory")