How to get default config of pylint?
Asked Answered
P

2

6

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.

Platinumblond answered 3/10, 2017 at 15:31 Comment(0)
R
5

Note that the documentation for --generate-rcfile (from 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.

(Emphasis mine.) In other words, --generate-rc-file depends on your existing configuration. It generates a configuration file that merges the default configuration with your existing one.

If you instead want the default, base configuration with no changes, you therefore should run it with an empty existing configuration. You can do that either by temporarily renaming ~/.pylintrc or by running pylint --rcfile="" --generate-rcfile.

Reseat answered 18/7, 2022 at 22:20 Comment(3)
Please read the question thoroughly, this is something the OP did run.Dump
@Dump I am aware that OP tried it, but I believe that the OP is misunderstanding what it does, hence the "with emphasis added". Additionally, OP did not run it with --rcfile="".Reseat
@Dump I've updated my answer for clarity. If you still disagree, please provide a counterexample that shows that it is wrong.Reseat
S
3

I just check the pylintrc file in the source tree of the pylint project. Not sure whether they are really the default values, but appears to be pretty close.

Sturmabteilung answered 30/8, 2018 at 21:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.