196

I am running linux. Can I do something like pylint --generate-rcfile > .pylintrc and then make changes to the resulting .pylintrc file to override the default settings? And if so should it be in my ~/ directory or should I put it in .pylint.d?

3 Answers 3

196

You may put it in:

  • /etc/pylintrc for default global configuration
  • ~/.pylintrc for default user configuration
  • <your project>/pylintrc for default project configuration (used when you'll run pylint <your project>)
  • wherever you want, then use pylint --rcfile=<wherever I want>

Also notice when generating the rc file, you may add option on the command line before the --generate-rcfile, they will be considered in the generated file.

10
  • 76
    I recommend against a system-wide or user-wide rc file. It is almost always good to have it per project, and saved in version control.
    – Asclepius
    Apr 19, 2017 at 16:03
  • 16
    IMO it doesn't hurt to have a user-wide rc file with the user's default settings, and have additional project-specific rc files where that is necessary for a project (still, +1 for your comment).
    – fotNelton
    Jun 19, 2017 at 11:44
  • 2
    You may also set the $PYLINTRC environment variable, pointing to your configuration file's location.
    – boxama
    Nov 21, 2017 at 20:13
  • 7
    Where do these go on windows?
    – Elliot
    Mar 18, 2018 at 14:39
  • 7
    .pylintrc in a project directory also gets picked up by default if pylintrc does not exist. pylint.pycqa.org/en/latest/user_guide/… Apr 10, 2019 at 20:14
144

According to documentation here, we can use the following command to generate a pylint rc file with all its options present:

pylint --generate-rcfile > ${HOME}/.pylintrc

The above command will create the file .pylintrc under your home directory. Then you can tweak the rc file to fit your needs.

4
3

There's a 'new experimental feature' to interactively generate a .pylintrc file.

pylint-config generate --interactive

Please choose the format of configuration, (T)oml or (I)ni (.cfg): T
Do you want a minimal configuration without comments or default values? (y)es or (n)o: n
Do you want to write the output to a file? (y)es or (n)o: y
What should the file be called: .pylintrc
Wrote configuration file to ~/.pylintrc

And as far as I can tell in the docs there isn't an obvious way to choose a config file, so prob best to put it in ~/ as previously suggested.

Hope that helps!

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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.