user3330833
user3330833

Reputation: 2329

How do I create a pylintrc file

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?

Upvotes: 211

Views: 200113

Answers (3)

Chase Sims
Chase Sims

Reputation: 61

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!

Upvotes: 6

jdhao
jdhao

Reputation: 28487

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.

Upvotes: 158

sthenault
sthenault

Reputation: 15125

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.

Upvotes: 204

Related Questions