How do I comment / use documents in Pylint mode?
Disabling Pylint validation or bypassing one of its warnings shouldn't be without a clear reason. I would like to comment on these reasons in the place where I disabled it; so far, without success.
As an example, let's say a class with only a constructor and one method. Which is what Peelint warns about for reasons, while there might be so many good reasons to turn off 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 warns about "too few public methods", but even additionally complains about "incorrect parameter value" R0903 --- "Closed object".
The question is broader rational than this single example (maybe I don't know a better way to achieve closure in Python), and I'd like to comment on most of these built-in directives, the same line, for clarity and simplicity. By the way, it can also be helpful to remind you what the option is for. For example, reminding # pylint: disable=R0903 --- Too few public methods
(to stay on one example).
In less words: is there a way to comment out Pylint directives in-line?
source to share
This works for me:
class Foo(object): # (Closure object) pylint: disable=R0903
def __init__(self, data):
…
def single_method(argument):
…
My pylint version
(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)]
source to share
Pylint does not support comment directives. But since 0.25.3 you can use symbolic names http://docs.pylint.org/faq.html#do-i-have-to-remember-all-these-numbers . If you want / need a comment you will have to use the second line (I usually add comments above my Pylint directives)
source to share