diff --git a/doc/whatsnew/fragments/374.bugfix b/doc/whatsnew/fragments/374.bugfix new file mode 100644 index 0000000000..21ea4ad151 --- /dev/null +++ b/doc/whatsnew/fragments/374.bugfix @@ -0,0 +1,3 @@ +Support ``duplicate-code`` message when parallelizing with ``--jobs``. + +Closes #374 diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py index 2b08204f2f..fae5f3a8dc 100644 --- a/pylint/checkers/similar.py +++ b/pylint/checkers/similar.py @@ -889,8 +889,11 @@ def reduce_map_data(self, linter: PyLinter, data: list[list[LineSet]]) -> None: """Reduces and recombines data into a format that we can report on. The partner function of get_map_data() + + Calls self.close() to actually calculate and report duplicate code. """ Similar.combine_mapreduce_data(self, linesets_collection=data) + self.close() def register(linter: PyLinter) -> None: diff --git a/pylint/lint/parallel.py b/pylint/lint/parallel.py index 72f770043f..34becdf3c3 100644 --- a/pylint/lint/parallel.py +++ b/pylint/lint/parallel.py @@ -130,7 +130,7 @@ def check_parallel( """Use the given linter to lint the files with given amount of workers (jobs). This splits the work filestream-by-filestream. If you need to do work across - multiple files, as in the similarity-checker, then implement the map/reduce mixin functionality. + multiple files, as in the similarity-checker, then implement the map/reduce functionality. """ # The linter is inherited by all the pool's workers, i.e. the linter # is identical to the linter object here. This is required so that diff --git a/tests/test_self.py b/tests/test_self.py index 48f914e35d..fd3bb5ff02 100644 --- a/tests/test_self.py +++ b/tests/test_self.py @@ -233,7 +233,6 @@ def test_parallel_execution(self) -> None: join(HERE, "functional", "a", "arguments.py"), ], out=out, - # We expect similarities to fail and an error code=MSG_TYPES_STATUS["E"], ) assert ( diff --git a/tests/test_similar.py b/tests/test_similar.py index 0f2ec242ce..ca58342c1d 100644 --- a/tests/test_similar.py +++ b/tests/test_similar.py @@ -82,6 +82,23 @@ def test_duplicate_code_raw_strings_all(self) -> None: expected_output=expected_output, ) + @pytest.mark.needs_two_cores + def test_duplicate_code_parallel(self) -> None: + path = join(DATA, "raw_strings_all") + expected_output = "Similar lines in 2 files" + self._test_output( + [ + path, + "--disable=all", + "--enable=duplicate-code", + "--ignore-imports=no", + "--ignore-signatures=no", + "--min-similarity-lines=4", + "--jobs=2", + ], + expected_output=expected_output, + ) + def test_duplicate_code_raw_strings_disable_file(self) -> None: """Tests disabling duplicate-code at the file level in a single file.""" path = join(DATA, "raw_strings_disable_file")