Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up Pylint to only do some inspections

Tags:

python

pylint

I'm trying to set up Pylint to only do certain inspections and no others, e.g. only check for W0601 and W0612. I've tried using an enable= line the the [MESSAGES CONTROL] section of my pylint.rc but that doesn't seem to do what I want.

I'm using Pylint 0.25.1.

like image 222
Peter Graham Avatar asked Jul 11 '12 23:07

Peter Graham


2 Answers

Looks like a bug with the way rc files are parsed.

Order matters on the command line (undocumented?) so you need to disable first then enable:

pylint xyz.py --disable R,C,W,E --enable W0601,W0612

But this is not reflected correctly with --generate-rcfile and does not work with --rcfile ...these are probably bugs. Like #36584.

In the rc file with the disable line, all messages get disabled, even with disable before enable like on the command line.

[MESSAGES CONTROL]
disable=R,C,W,E
enable=W0601,W0612
like image 142
aneroid Avatar answered Sep 30 '22 05:09

aneroid


@aneroid: you may be right that there could be order issue in generating/reading the configuration file; and also that the fact that order matters on the command line should be documented. I've planified and commented the ticket you refer to accordingly.

@peter-graham, so your probably have to use the command line to achieve this until the #36584 ticket is fixed. I would recommend :

pylint --disable-all --enable=W0601,W0612
like image 24
sthenault Avatar answered Sep 30 '22 06:09

sthenault