Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable a Pylint warning?

Tags:

python

pylint

I'm trying to disable warning C0321 ("more than one statement on a single line" -- I often put if statements with short single-line results on the same line), in Pylint 0.21.1 (if it matters: astng 0.20.1, common 0.50.3, and Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)).

I've tried adding disable=C0321 in the Pylint configuration file, but Pylint insists on reporting it anyway. Variations on that line (like disable=0321 or disable=C321) are flagged as errors, so Pylint does recognize the option properly. It's just ignoring it.

Is this a Pylint bug, or am I doing something wrong? Is there a way around this?

I'd really like to get rid of some of this noise.

like image 839
Head Geek Avatar asked Dec 03 '10 01:12

Head Geek


People also ask

How do you make a Pylint ignore an error?

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.

How do I know if a Pylint is ignoring a file?

The solution was to include --disable=file-ignored in the Pylint command options.


1 Answers

pylint --generate-rcfile shows it like this:

[MESSAGES CONTROL]  # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option # multiple time. #enable=  # Disable the message, report, category or checker with the given id(s). You # can either give multiple identifier separated by comma (,) or put this option # multiple time (only on the command line, not in the configuration file where # it should appear only once). #disable= 

So it looks like your ~/.pylintrc should have the disable= line/s in it inside a section [MESSAGES CONTROL].

like image 180
Chris Morgan Avatar answered Oct 15 '22 21:10

Chris Morgan