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.

Peter Graham
  • 11,323
  • 7
  • 40
  • 42

3 Answers3

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
aneroid
  • 12,983
  • 3
  • 36
  • 66
13

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.

Cas
  • 6,123
  • 3
  • 36
  • 35
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
sthenault
  • 14,397
  • 5
  • 38
  • 32