Skip to main content

pylint-venv provides a Pylint init-hook to use the same Pylint installation with different virtual environments.

Project description

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.

Installation

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 without pylint is active,

  • or a Conda environment without pylint is active,

  • or no environment is active but your CWD contains virtualenv directory.

Anything listed in the PYLINT_VENV_PATH environment variable is considered a virtualenv directory. The default, if the variable is unset, is .venv. Use a colon (:) as path separator. Example for checking directories .venv and .virtualenv:

PYLINT_VENV_PATH=.venv:.virtualenv

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')"

If pylint itself is installed in a virtualenv, then you can ignore it by passing force_venv_activation=True to force the activation of a different virtualenv:

$ pylint --init-hook="import pylint_venv; pylint_venv.inithook(force_venv_activation=True)"

This will try to automatically detect virtualenv and activate it.

Troubleshooting

General

pylint_venv fails to import

Most likely pylint-venv is not installed in the same virtual environment as pylint. Either make sure to ensure pylint-venv into the same virtual environment as pylint, or add the appropriate path in the init hook:

import sys
sys.path.append("/path/to/installation/folder/of/pylint_venv")

Virtual environment does not get used (installed modules are reported as ‘unable to import’)

Most likely the virtual environment does not get activated because pylint itself runs in a virtual environment. You can force the activation of the virtual environment with the force_venv_activation=True flag to the pylint_venv.inithook function.

Homebrew

Homebrew installs pylint into a separate virtual environment, thus you will need to set the force_venv_activation=True flag. This also means, that pylint_venv will be in a different search path and you must add the proper path to sys.path. You can use the following configuration adjusted to your Python version:

init-hook=
    import sys
    sys.path.append("/usr/local/lib/python3.8/site-packages")
    try: import pylint_venv
    except ImportError: pass
    else: pylint_venv.inithook(force_venv_activation=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylint-venv-2.2.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylint_venv-2.2.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file pylint-venv-2.2.0.tar.gz.

File metadata

  • Download URL: pylint-venv-2.2.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.13 Darwin/20.6.0

File hashes

Hashes for pylint-venv-2.2.0.tar.gz
Algorithm Hash digest
SHA256 6c5317a6ac703a682bc77ab5819a3b7431d6df7fac91fd53555b3f7563cbf0bd
MD5 fd4cba10758565bdb02db2a6c9c6e200
BLAKE2b-256 ebb02a99950375e32cfd9289a24823e36901e239575a5ee3ba67c42cf93c4381

See more details on using hashes here.

File details

Details for the file pylint_venv-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: pylint_venv-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.13 Darwin/20.6.0

File hashes

Hashes for pylint_venv-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 182121538c9748a11a6db7b9451b0768c60aada484751572350f83ccec4d17e6
MD5 1157923c014425982ea91d1920e27338
BLAKE2b-256 92ec5ee787760e9bd7fd5b7a7be711f201723e6341b4cae4960bd6e4e4b23352

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page