-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load custom plugins when linting in parallel #8683
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
``--jobs`` can now be used with ``--load-plugins``. | ||
|
||
This had regressed in astroid 2.5.0. | ||
|
||
Closes #4874 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,11 @@ | |
from concurrent.futures import ProcessPoolExecutor | ||
from concurrent.futures.process import BrokenProcessPool | ||
from pickle import PickleError | ||
from typing import TYPE_CHECKING | ||
from unittest.mock import patch | ||
|
||
import dill | ||
import pytest | ||
from astroid import nodes | ||
|
||
import pylint.interfaces | ||
import pylint.lint.parallel | ||
|
@@ -30,6 +31,9 @@ | |
from pylint.typing import FileItem | ||
from pylint.utils import LinterStats, ModuleStats | ||
|
||
if TYPE_CHECKING: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure this helps much? If you are running this test then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we shouldn't reject change because it's only a small improvments. It's better, let's ship it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair, I just prefer this conceptually, when it comes in handy in more substantial cases. We can probably trace this to the opposite views we expressed on #8111 :-) |
||
from astroid import nodes | ||
|
||
|
||
def _gen_file_data(idx: int = 0) -> FileItem: | ||
"""Generates a file to use as a stream.""" | ||
|
@@ -182,6 +186,17 @@ def test_worker_initialize_with_package_paths(self) -> None: | |
) | ||
assert "fake-path" in sys.path | ||
|
||
def test_worker_initialize_reregisters_custom_plugins(self) -> None: | ||
linter = PyLinter(reporter=Reporter()) | ||
linter.load_plugin_modules(["pylint.extensions.private_import"]) | ||
|
||
pickled = dill.dumps(linter) | ||
with patch( | ||
"pylint.extensions.private_import.register", side_effect=AssertionError | ||
): | ||
with pytest.raises(AssertionError): | ||
worker_initialize(linter=pickled) | ||
|
||
@pytest.mark.needs_two_cores | ||
def test_worker_initialize_pickling(self) -> None: | ||
"""Test that we can pickle objects that standard pickling in multiprocessing can't. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a map reduce function for that I think. But some are not implemented (they should). For duplicate code I don't even know if it's possible to parralelize. The whole hashmap of lines should be shared.