Skip to content

Commit

Permalink
Fix a crash in parallel mode when the module's filepath is not set
Browse files Browse the repository at this point in the history
Close #3564
  • Loading branch information
PCManticore committed Jun 20, 2020
1 parent 4e2529c commit da91a9a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Expand Up @@ -2,6 +2,7 @@
Pylint's ChangeLog
------------------


What's New in Pylint 2.5.4?
===========================

Expand All @@ -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?
===========================
Expand Down
14 changes: 10 additions & 4 deletions pylint/lint/check_parallel.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
Empty file.
8 changes: 8 additions & 0 deletions tests/test_self.py
Expand Up @@ -783,3 +783,11 @@ def test_jobs_score(self):
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")

0 comments on commit da91a9a

Please sign in to comment.