I saw I can change it per Eclipse instance using this solution. I would like to set it per project. Is it possible?
This is not Eclipse specific, but it may help anyway. According to pylint command line options:
You can specify a configuration file on the command line using the
--rcfile
option. Otherwise, Pylint searches for a configuration file in the following order and uses the first one it finds:
pylintrc
in the current working directory.pylintrc
in the current working directory- If the current working directory is in a Python module, Pylint searches up the hierarchy of Python modules until it finds a
pylintrc
file. This allows you to specify coding standards on a module-by-module basis. Of course, a directory is judged to be a Python module if it contains an__init__.py
file.- The file named by environment variable
PYLINTRC
- If you have a home directory which isn’t
/root
:
.pylintrc
in your home directory.config/pylintrc
in your home directory/etc/pylintrc
Points 1 or 3 above may help.
Simply put a configuration file named pylintrc (with no '.') in the root directory of each project. Pylint is run with the project directory as the current working directory, and this is the first place that pylint looks for a configuration file.
The PyDev documentation suggests naming the file .pylintrc, but this is less robust because ./.pylintrc is almost last in the order of places that pylint will search. The PyDev documentation further says that this only works for PyDev 2.8.0 and above, but I am using PyDev 2.6.0 and it works for me.
The search order for the configuration file in the other answer is not quite right. I just submitted an enhancement to the Pylint documentation that describes the configuration file search order correctly:
You can specify a configuration file on the command line using the --rcfile option. Otherwise, Pylint searches for a configuration file in the following order and uses the first one it finds:
- pylintrc in the current working directory
- If the current working directory is in a Python module, Pylint searches up the hierarchy of Python modules until it finds a pylintrc file. This allows you to specify coding standards on a module-by-module basis. Of course, a directory is judged to be a Python module if it contains an
__init__.py
file.- The file named by environment variable PYLINTRC
- .pylintrc in your home directory, unless you have no home directory or your home directory is /root
- .pylintrc in the current working directory
- /etc/pylintrc
Note that the configuration file only applies to Python files that are in modules. Thus, Pylint still uses its default rules when analyzing Python files in a directory with no __init__.py
file. Perhaps it is this problem that is fixed in PyDev 2.8.0.
For example, I have a bin/
directory containing command line applications. Ordinarily, this directory needs no __init__.py
file because it is never imported. I had to add a bin/__init__.py
file to get Pylint to analyze these Python files using my pylintrc
file.
© 2022 - 2024 — McMap. All rights reserved.