13

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.

3 Answers 3

14

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
14

In Pylint >= 0.27 there is a new --disable=all option

pylint --disable=all --enable=W0201

or

pylint -d all -e W0201

You can put it in rc file but as aneroid points out there is a bug still that means you cannot then enable any messages, except from command line, so:

[MESSAGES CONTROL]
disable=all

then

pylint -e W0201

would work.

1

@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
2
  • 3
    Pylint gives me 'no such option' if I try to use --disable-all. pylint --disable=I,C,R,W,E,F --enable=W0601,W0612 works though. Jul 12, 2012 at 23:04
  • --disable=all instead of --disable-all
    – kissgyorgy
    Jun 14, 2015 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.