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?
How do I create a pylintrc file
Asked Answered
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.
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. –
Castile
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). –
Koontz
You may also set the $PYLINTRC environment variable, pointing to your configuration file's location. –
Cranium
Where do these go on windows? –
Jealousy
.pylintrc
in a project directory also gets picked up by default if pylintrc
does not exist. pylint.pycqa.org/en/latest/user_guide/… –
Arthur @Jealousy 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. –
Quarto
I want to know where to put .pylintrc file for its application in global scope in windows. Any suggestions ? –
Quarto
@Jealousy Look at the following answer #1372795 –
Quarto
https://docs.pylint.org/en/1.6.0/run.html#command-line-options
scroll down a little for pylintrc
locations –
Lumbago Vote down because of the missing link to the official documentation. –
Herrle
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.
I think you mean
pylint --generate-rcfile > .pylintrc
. ~
means $HOME
–
Yogini yeah,
~
means $HOME in Linux. Maybe I should change it to $HOME
to be more explicit. –
Abutting better
${HOME}
since is a shell parameter expansion
‣ https://mcmap.net/q/40691/-when-do-we-need-curly-braces-around-shell-variables and gnu.org/software/bash/manual/html_node/… –
Classic the example command to generate the rc file no longer appears in the faq, it now appears in this page. –
Hyperbola
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!
© 2022 - 2024 — McMap. All rights reserved.