Search code examples
pythonwindowspylint

Setting up default pylint config.rc file in Windows


I'm using Pylint under Windows, and it's not reading my pylint-config.rc file. Is there a way to set up a default .rc file for Python within windows so that I don't have to keep typing it into the command line? Thanks.


Solution

  • I don't have a windows box at hand to test, but the code uses os.path.expanduser('~') to find the current user's home directory, and looks for a file calle .pylintrc in that directory.

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

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

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

    Alternatively, if you want to use different configuration files on a per project basis, you should know that if there is a file called pylintrc (without a leading dot) in the current working directory, then Pylint will use this one. If there is a file called __init__.py in the current working directory, Pylint will look in the parent directory until there is no such file and then look for a pylintrc configuration file. This is done so that you can maintain a per project config file together with you source code, and lauch Pylint from any directory in your source tree.