How to get default config of pylint?

Viewed 6195

I will use this simple Python file for illustrating my problem:

import os

for i in range( -500, 0 ):
    print i

I run Pylint on this file and get one message:

$ pylint foobar.py
************* Module foobar
W:  1, 0: Unused import os (unused-import)

Now I want to disable warning messages of the type unused-import. But I want to add that on top of the default configuration of Pylint.

I thought this gives me the default config of Pylint, cause help of --generate-rcfile says it generates current configuration:

$ pylint --generate-rcfile > pylintrc

When I run Pylint again on the same file, I now get a lot more messages:

************* Module foobar
C:  3, 0: No space allowed after bracket
for i in range( -500, 0 ):
              ^ (bad-whitespace)
C:  3, 0: No space allowed before bracket
for i in range( -500, 0 ):
                        ^ (bad-whitespace)
C:  1, 0: Missing module docstring (missing-docstring)
W:  1, 0: Unused import os (unused-import)

Why is the bad-whitespace message getting triggered only after the pylintrc was generated? Is bad-whitespace disabled by default? How do I get the actual default config of pylint?

So, if the --generate-rcfile is not giving me the default config, what is the config options it outputs? How do I get the default config of Pylint in the pylintrc format? So that I can add my settings on top of that.

2 Answers

pylint --help states:

--generate-rcfile

Generate a sample configuration file according to the current configuration. You can put other options before this one to get them in the generated configuration.

(with emphasis added). Therefore, pylint --generate-rcfile already generates a default configuration file that incorporates your existing one on top.

If you really want the actual default configuration with no changes, you can temporarily rename ~/.pylintrc or run pylint --rcfile="" --generate-rcfile.

Related