Setting default pylint config.rc file on Windows

I use Pylint on Windows and it does not read my pylint-config.rc file. Is there a way to configure the default .rc file for Python in windows so that I don't have to enter it on the command line? Thanks.

+6
source share
3 answers

I do not have a window to check, but the code uses os.path.expanduser('~') to search for the user's current home directory and looks for the calle .pylintrc file in this directory.

According to python documentation , on Windows, expanduser uses HOME and USERPROFILE if they are installed, otherwise a combination of HOMEPATH and HOMEDRIVE. So my advice is to check the following script outputs in an interactive Python session:

 import os print os.path.expanduser('~') 

and put the configuration file as .pylintrc in this folder.

Alternatively, if you want to use different configuration files for each project, you should know that if there is a file called pylintrc in the current working directory (without a leading point), then Pylint will use this. If there is a file in the current working directory with With the name __init__.py , Pylint will look in the parent directory until there is such a file, and then find the pylintrc configuration pylintrc . This is done so that you can maintain the project configuration file along with the source code and lauch Pylint from any directory in the source code.

+13
source

Since creating a file starting with a period is not allowed from Windows Explorer, you can create a template using:

 pylint --generate-rcfile > .pylintrc 
+5
source

There are two possible ways to do this. One way is to edit the file C:\Python\Scripts\pylint.bat by changing the line

 python "%~dpn0" %* 

to

 python "%~dpn0" %* --rcfile="C:\path\to\pylint.rc" 

Another way is to add an environment variable. Do this by going to Start->Control Panel->System , then go to the Advanced tab and click Environment Variables . Then click New and create a variable called PYLINTRC with the value C:\path\to\pylint.rc .

+3
source

All Articles