Pylint does not respect the currently activated virtualenv if it is not installed in every virtual environment individually. This module provides a Pylint init-hook to use the same Pylint installation with different virtual environments.
pip install pylint-venv
Add the following to your ~/.pylintrc
:
init-hook=
try: import pylint_venv
except ImportError: pass
else: pylint_venv.inithook()
The hook will then be used automatically if
- a virtualenv is activated
- a Conda environment is activated
- no env is activated but your CWD contains a virtualenv in
.venv
and if pylint is not installed in that env, too.
You can also call the hook via a command line argument:
$ pylint --init-hook="import pylint_venv; pylint_venv.inithook()"
This way you can also explicitly set an environment to be used:
$ pylint --init-hook="import pylint_venv; pylint_venv.inithook('$(pwd)/env')"