The documentation in section 4.1 clearly states:
https://pylint.readthedocs.io/en/latest/faq.html#message-control
4.1 Is it possible to locally disable a particular message?
Yes, this feature has been added in Pylint 0.11. This may be done by adding “#pylint: disable=some-message,another-one” at the desired block level or at the end of the desired line of code
Great! but it doesn't work. Boo.
I get the the following pylint error for the following line of code
W: 26, 2: Redefining built-in 'zip' (redefined-builtin)
try:
from itertools import izip as zip # pylint: disable=bad-builtin
except ImportError:
pass
But pylint just complains even louder about my attempt to shut it up:
E: 26, 0: Bad option value 'bad-builtin' (bad-option-value)
I've also tried the error code # pylint: disable=W0141
, that also produces a similar error.
Any idea what I'm doing wrong?
I have been in a similar situation.
class A:
pass
There are many warnings in pylint
for the code above, but I want to talk about old-style-class
.
In Python 2.7, you will get an old-style-class
error.
Of course, you can change your code like this:
class A(object):
pass
However, you will receive a useless-object-inheritance
warning in Python 3.
If you are writing a package compatible with python 2.7 and 3 and using pylint
, then you are down.
Yes, if it is accepted to disable either of old-style-class
or useless-object-inheritance
in a comment, you can go further.
In Python 2.7:
# pylint: disable=old-style-class
class A:
pass
In Python 3:
# pylint: disable=useless-object-inheritance
class A(object):
pass
Eventually, you will get a bad-option-value
, just the same as this question.
I have tried, but bad-option-value
can not be disabled locally in this case.
I have to disable bad-option-value
in a pylint
configuration file, like .pylintrc
.
[TYPECHECK]
disable=bad-option-value
Note: My pylint
version is 1.9.4 in python 2.7, 2.2.2 in python 3.
Ah, simple answer, it should be # pylint: disable=bad-option-value
which is presented in the error message in parenthesis:
E: 26, 0: Bad option value 'bad-builtin' (bad-option-value)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With