Disabling a Pylint check or getting around one of its warnings, should not be without a clear reason. I would like to be able to comment these reasons at the place I'm disabling it; so far, without success.
As an example, let a class with just a constructor and a single method. The kind of thing Pylint warns about with reasons, while there may be as much good reasons to disable this warning locally.
class Foo(object): # pylint: disable=R0903 --- Closure object
def __init__(self, data):
…
def single_method(argument):
…
With the above, Pylint not only still warns about “too few public methods” but even additionally complains about “bad option value 'R0903 --- Closure object'”.
The question has a wider rational than this single example (may be I'm not aware of a better way to achieve closures in Python), and I would like to be able to comment most of these in‑line directives, on the same line, for clarity, and simplicity. By the way, may also be useful to remind about what an option is for. As an example, reminding # pylint: disable=R0903 --- Too few public methods
(to stay on the same example).
In less words: is there a way to comment Pylint in‑line directives?
you can ignore it by adding a comment in the format # pylint: disable=[problem-code] at the end of the line where [problem-code] is the value inside pylint(...) in the pylint message – for example, abstract-class-instantiated for the problem report listed above.
Since pylint 1.5.0, you can do # pylint: disable=no-member; any text here
.
This works for me:
class Foo(object): # (Closure object) pylint: disable=R0903
def __init__(self, data):
…
def single_method(argument):
…
My pylint version is
(doisub)> $ pylint --version
pylint 1.5.4,
astroid 1.4.4
Python 2.7.11 (default, Dec 22 2015, 11:45:03)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]
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