-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Transform plugin not called when running with multiple jobs #4874
Comments
Upgraded pylint using pip and can confirm the same behavior for 2.9.6 > python -m pylint --version
pylint 2.9.6
astroid 2.6.6
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] |
For the record, this bug specifically happens on Pylint >= 2.5 on a platform for which
Note that this works fine on versions of Pylint < 2.5. With the example above:
Also note that things work fine on a platform such as Linux:
It looks like this bug was introduced by this big refactor: #3016 (you can see some plugin loading code getting removed here), which I believe went out in Pylint 2.5. That change relies upon the (IMO, incorrect) assumption that the only side effects of Pylint plugins are to alter the For the record, it was really hard for me to tell if this is a known bug or not. https://pylint.pycqa.org/en/latest/user_guide/run.html#parallel-execution says:
So it sort of sounds like this is a known issue, but then I went digging to see if there's a corresponding issue, and I learned that the history is a little more interesting than that:
|
Some ideas:
@Pierre-Sassoulas any thoughts? |
Thank you for analyzing the problem in detail like that, much appreciated. I think you're solution sounds great. Why not do 1 and 2 though ? It seems we want both register and init-hook options to works ? Baring that it seems to me that the hard part (now that you identified the problem properly, because clearly THAT was the hard part) would be to create a proper automated tests for it. We have some automated tests with multiprocessing, but not using optional plugin yet. Maybe it's as simple as adding an optional plugin that would be easily testable to the existing tests. How would you test this ? |
When I made the #3016 I first tried to separate configuration and the actual linting (see #3016 (comment)) but that basically would have resulted in changing pretty much everything related to launching pylint, i.e. you would have had to basically rewrite everything for launching pylint. I did not have the changes I made when trying this out in my git clone anymore but I still remember that it started to look like a complete rewrite. |
@Pierre-Sassoulas unfortunately I'm pretty busy, so I don't think I'll have time to actually put together a PR for this, sorry. For anyone else showing up from the internet, we're working around this by using
I don't know if we're opening ourselves up to any bugs here. https://bugs.python.org/issue33725 talks about this at length, and it sounds like CPython changed the default start_method on macOS for a good reason. Oh well. 🤞 🤷 |
Also fork method is not available on Windows. I also considered changing the start method to fork but that does not work on Windows and like you mentioned, the fork method should not be used on MacOS:
https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods I think that if you want to really fix this, the whole implementation for running pylint parallel needs to be rewritten. As far as I can remember, the code starting Pylint has a lot of dependencies and is very complex. Like I said, I tried to refactor it in such way that configuration and starting would be separated but that ended up looking like a complete rewrite and I'm not sure what existing features the change would break. Of course, it could also be that I spent only something like 20 - 30 hours digging into the implementation. |
You're right, We did some refactor since though and it now "only" inherit from There is also a need to separate the option parsing for #5392. One of the issue is that the each checker is parsing the option itself. So, maybe it got a little better and #5392 will help |
Update: The PyLinter got simpler following the argparse refactor, this is not something as hard as when we were first discussing it. |
Summary
When adding a plugin which registers a transform it registers and calls the transform as expected, but when enabling multiple jobs, the transform doesn't get called resulting in a different result than expected.
The plugin seems to be loaded fine, but the transform is not triggered.
The expected behavior is to have the linting result be the same regardless of the number of jobs.
Pylint version
MWE
With the content of
mwe.py
being:You get the following error when running pylint without plugins:
This is most likely since it can't figure out what the decorator is doing (similar to #259 but for the class decorator).
If we enable the plugin which adds the arg back using the transform (since we can't use
signature-mutators
as it doesn't seem to work as expected here) we see that the error disappearsIf we however increase the number of jobs, we see that plugin is registered, but the transform not triggered, resulting in the error returning
Related issues
The text was updated successfully, but these errors were encountered: