Skip to content

Commit 35f838f

Browse files
committed
Fix a crash in parallel mode when the module's filepath is not set
Close #3564
1 parent 36250aa commit 35f838f

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Pylint's ChangeLog
44

55
What's New in Pylint 2.6.0?
66
===========================
7+
78
Release date: TBA
89

910
* bad-continuation and bad-whitespace have been removed, black or another formatter can help you with this better than Pylint
@@ -34,6 +35,10 @@ Release date: TBA
3435

3536
* Fix `pre-commit` config that could lead to undetected duplicate lines of code
3637

38+
* Fix a crash in parallel mode when the module's filepath is not set
39+
40+
Close #3564
41+
3742

3843
What's New in Pylint 2.5.4?
3944
===========================
@@ -42,6 +47,10 @@ What's New in Pylint 2.5.4?
4247

4348
Close #3690
4449

50+
* Fix a crash in parallel mode when the module's filepath is not set
51+
52+
Close #3564
53+
4554

4655
What's New in Pylint 2.5.3?
4756
===========================

pylint/lint/check_parallel.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def _worker_check_single_file(file_item):
7171
msgs = [_get_new_args(m) for m in _worker_linter.reporter.messages]
7272
return (
7373
_worker_linter.current_name,
74+
filepath,
7475
_worker_linter.file_state.base_name,
7576
msgs,
7677
_worker_linter.stats,
@@ -98,11 +99,16 @@ def check_parallel(linter, jobs, files, arguments=None):
9899

99100
all_stats = []
100101

101-
for module, base_name, messages, stats, msg_status in pool.imap_unordered(
102-
_worker_check_single_file, files
103-
):
102+
for (
103+
module,
104+
file_path,
105+
base_name,
106+
messages,
107+
stats,
108+
msg_status,
109+
) in pool.imap_unordered(_worker_check_single_file, files):
104110
linter.file_state.base_name = base_name
105-
linter.set_current_module(module)
111+
linter.set_current_module(module, file_path)
106112
for msg in messages:
107113
msg = Message(*msg)
108114
linter.reporter.handle_message(msg)

tests/regrtest_data/regression_missing_init_3564/subdirectory/file.py

Whitespace-only changes.

tests/test_self.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,3 +791,11 @@ def test_duplicate_code_raw_strings(self):
791791
[path, "--disable=all", "--enable=duplicate-code"],
792792
expected_output=expected_output,
793793
)
794+
795+
def test_regression_parallel_mode_without_filepath(self):
796+
# Test that parallel mode properly passes filepath
797+
# https://github.com/PyCQA/pylint/issues/3564
798+
path = join(
799+
HERE, "regrtest_data", "regression_missing_init_3564", "subdirectory/"
800+
)
801+
self._test_output([path, "-j2"], expected_output="No such file or directory")

0 commit comments

Comments
 (0)