-
-
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
Ordering of modules on command line affects reported errors #3611
Comments
I discovered this issue when trying to figure out why one particular environment in which we run This feels like something to do with the ordering of tests within the processes that pylint is running: without |
By applying this diff: diff --git a/pylint/lint/check_parallel.py b/pylint/lint/check_parallel.py
index 480dae73..4b5c2b25 100644
--- a/pylint/lint/check_parallel.py
+++ b/pylint/lint/check_parallel.py
@@ -65,6 +65,8 @@ def _worker_initialize(linter, arguments=None):
def _worker_check_single_file(file_item):
name, filepath, modname = file_item
+ print(multiprocessing.current_process(), name)
+
_worker_linter.open()
_worker_linter.check_single_file(name, filepath, modname) I can see which workers are linting which file. And there's an interesting difference with
but when it's the first module tested by a worker, then we do:
|
We recently discovered that pylint is failing to report some errors when invoked across our entire codebase (see pylint-dev/pylint#3611). I've run pylint across every Python file under cloudinit/[0], and this commit fixes the issues so-discovered. [0] find cloudinit/ -name "*.py" | xargs -n 1 -t .tox/pylint/bin/python -m pylint
I have something like too (hopefully it's related and I'm not highjacking the issue) $ pylint $opts pynar.access_control.rfid.serial
pynar/access_control/rfid/serial.py:148: [E1135(unsupported-membership-test), SerialReaderManager.initialize] Value 'exc.strerror' doesn't support membership test
------------------------------------------------------------------
Your code has been rated at 9.83/10 (previous run: 9.83/10, +0.00)
$ pylint $opts pynar
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
Then, trying to narrow it down (and after adding a bunch of prints to figure out what pylint was up to): $ pylint $opts pynar.ws pynar.access_control
-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 9.98/10, +0.02)
$ pylint $opts pynar.access_control pynar.ws
************* Module pynar.access_control.rfid.serial
pynar/access_control/rfid/serial.py:148: [E1135(unsupported-membership-test), SerialReaderManager.initialize] Value 'exc.strerror' doesn't support membership test
-----------------------------------
Your code has been rated at 9.98/10
I'm going to go further down the rabbit hole to figure out what in my sub-package |
OK, so I think I've worked out more of the underlying issue. And, unfortunately, it does involve digging into the cloud-init codebase a little, so bear with me.
This monkeypatching means that pylint/astroid cannot infer a single type for So I think there are two distinct problems here: (a) pylint cannot infer the type of I don't think there's anything pylint can (or should) do to address (a); our codebase gives contradictory definitions for Interesting Inference InvestigationWith a breakpoint on ipdb> p list(owner.igetattr(self.attrname, context))
[<FunctionDef.subp l.2014 at 0x7fb0bf1b77f0>] And, as we would expect, this is the invocation that does report the error (because it is able to infer a type for With p list(owner.igetattr(self.attrname, context))
[<FunctionDef.subp l.2014 at 0x7f2f58fc5490>,
<FunctionDef.subp l.2014 at 0x7f2f58fc5490>,
Uninferable,
<BoundMethod _fake_subp of cloudinit.tests.helpers.CiTestCase at 0x139841250223488,
Uninferable,
Uninferable] And, also as we would expect at this point, this means that the error is not reported, because pylint isn't able to determine what the call signature for |
An aside: we inadvertently "fixed" this in cloud-init master by adding an import of the monkey-patching module to @RemiCardona I agree that your issue looks similar. That said, if you don't think that your issue is to do with inferred types changing based on the order in which modules are processed, then it's probably more appropriate as a separate issue. |
A simpler reproducer that doesn't involve explicitly ordering modules on the CLI:
(Though note that this is not only an issue when multiprocessing, as the explicit ordering of modules with |
We recently discovered that pylint is failing to report some errors when invoked across our entire codebase (see pylint-dev/pylint#3611). I've run pylint across every Python file under cloudinit/[0], and this commit fixes the issues so-discovered. [0] find cloudinit/ -name "*.py" | xargs -n 1 -t .tox/pylint/bin/python -m pylint
I've opened another bug to reduce the noise here, but they could very well still be related, at least in part. Cheers. |
We recently discovered that pylint is failing to report some errors when invoked across our entire codebase (see pylint-dev/pylint#3611). I've run pylint across every Python file under cloudinit/[0], and this commit fixes the issues so-discovered. [0] find cloudinit/ -name "*.py" | xargs -n 1 -t .tox/pylint/bin/python -m pylint
We have a similar error when upgrading from With Isolating the version While keeping the option
|
Steps to reproduce
cloud-init
repo, and I haven't yet found a minimal reproducer, so:git clone https://github.com/canonical/cloud-init
git reset --hard d10ce3ecf
pylint -j1 cloudinit.tests.test_util cloudinit.tests.test_conftest
pylint -j1 cloudinit.tests.test_conftest cloudinit.tests.test_util
Current behavior
Different output for each run:
Expected behavior
The same output for each run.
pylint --version output
but I have observed this on pylints back to what
pip install pylint<2.1
gave me (with the same Python version), and reproduced in a xenial container to be sure:The text was updated successfully, but these errors were encountered: