I'm using pre-commit for most of my Python projects, and in many of them, I need to use pylint as a local repo. When I want to commit, I always have to activate python venv and then commit; otherwise, I'll get the following error:
black....................................................................Passed
pylint...................................................................Failed
- hook id: pylint
- exit code: 1
Executable `pylint` not found
When I use vscode version control to commit, I get the same error; I searched about the problem and didn't find any solution to avoid the error in VSCode.
This is my typical .pre-commit-config.yaml
:
repos:
- repo: https://github.com/ambv/black
rev: 21.9b0
hooks:
- id: black
language_version: python3.8
exclude: admin_web/urls\.py
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: python
types: [python]
args:
- --rcfile=.pylintrc
CodePudding user response:
you have ~essentially two options here -- neither are great (language: system
is kinda the unsupported escape hatch so it's on you to make those things available on PATH
)
you could use a specific path to the virtualenv entry: venv/bin/pylint
-- though that will reduce the portability.
or you could start vscode with your virtualenv activated (usually code .
) -- this doesn't always work if vscode is already running
disclaimer: I created pre-commit