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?
Asked
Active
Viewed 1.7e+01k times
196

Kara
- 6,115
- 16
- 50
- 57

user3330833
- 2,179
- 2
- 12
- 9
3 Answers
195
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 runpylint <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.

sthenault
- 14,397
- 5
- 38
- 32
-
76I 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 '17 at 16:03
-
16IMO 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 '17 at 11:44
-
2You may also set the $PYLINTRC environment variable, pointing to your configuration file's location. – boxama Nov 21 '17 at 20:13
-
7Where do these go on windows? – Elliot Mar 18 '18 at 14:39
-
7`.pylintrc` in a project directory also gets picked up by default if `pylintrc` does not exist. http://pylint.pycqa.org/en/latest/user_guide/run.html?highlight=pylintrc#command-line-options – Taylor D. Edmiston Apr 10 '19 at 20:14
-
1@Elliot you run 'pylint --generate-rcfile > .pylintrc' in your directory where your python program is situated. Make changes in the .pylintrc file after opening it in the notepad++, save the changes and run the python program in that directory. It works. However, I was looking for a solution that will implement this change in the global scope and not just in the directory. If you find that please let me know. – rahul rachh Jan 28 '20 at 05:46
-
I want to know where to put .pylintrc file for its application in global scope in windows. Any suggestions ? – rahul rachh Jan 28 '20 at 06:06
-
@Elliot Look at the following answer https://stackoverflow.com/questions/1372295/how-to-specify-a-configuration-file-for-pylint-under-windows – rahul rachh Jan 28 '20 at 06:44
-
`https://docs.pylint.org/en/1.6.0/run.html#command-line-options` scroll down a little for `pylintrc` locations – noobninja May 01 '20 at 13:13
-
Vote down because of the missing link to the official documentation. – pylover Nov 06 '20 at 20:07
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.

jdhao
- 24,001
- 18
- 134
- 273
-
1I think you mean `pylint --generate-rcfile > .pylintrc`. `~` means `$HOME` – Iddan Aaronsohn Jan 07 '20 at 00:17
-
1yeah, `~` means $HOME in Linux. Maybe I should change it to `$HOME` to be more explicit. – jdhao Jan 07 '20 at 01:59
-
better `${HOME}` since is a `shell parameter expansion` ‣ https://stackoverflow.com/a/8748880/3889948 and https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html – manus Apr 20 '22 at 05:31
-
the example command to generate the rc file no longer appears in the faq, it now appears in [this page](https://pylint.pycqa.org/en/latest/user_guide/configuration/index.html). – Jean Paul Nov 29 '22 at 11:27
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!

Chase Sims
- 31
- 3