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.3e+01k times
175
Kara
- 5,996
- 16
- 49
- 56
user3330833
- 1,959
- 2
- 10
- 9
3 Answers
176
You may put it in:
/etc/pylintrcfor default global configuration~/.pylintrcfor default user configuration<your project>/pylintrcfor 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
- 13,029
- 4
- 35
- 31
-
59I 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
-
13IMO 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
-
1You 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
118
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
- 18,183
- 11
- 116
- 203
-
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
0
Windows user here. In my case, I just wanted to make an empty .pylintrc file but Windows doesn't allow it from Folder Explorer. So I had to run from command line:
echo dummyText > .pylintrc
datchung
- 2,490
- 22
- 21