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
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.
-
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. Apr 19, 2017 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). Jun 19, 2017 at 11:44
-
2You may also set the $PYLINTRC environment variable, pointing to your configuration file's location.– boxamaNov 21, 2017 at 20:13
-
7
-
7
.pylintrc
in a project directory also gets picked up by default ifpylintrc
does not exist. pylint.pycqa.org/en/latest/user_guide/… Apr 10, 2019 at 20:14
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.
-
1I think you mean
pylint --generate-rcfile > .pylintrc
.~
means$HOME
Jan 7, 2020 at 0:17 -
1yeah,
~
means $HOME in Linux. Maybe I should change it to$HOME
to be more explicit.– jdhaoJan 7, 2020 at 1:59 -
better
${HOME}
since is ashell parameter expansion
‣ stackoverflow.com/a/8748880/3889948 and gnu.org/software/bash/manual/html_node/…– manusApr 20, 2022 at 5:31 -
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!