0

I have a python project running in a virtual environment (created by poetry).

pylint is installed only in the virtual environment, not in the base.

pylint works well in the venv from command line, via pre-commit and inside Visual Studio Code which I start from the command line (poetry shell).

GitHub desktop cannot be started from the venv command line and when I try using it to commit my updated code it fails because the pre-commit hooks are launched and fail since it does not find pylint.

How to fix (other than installing pylint in the base env)?

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
Robert Alexander
  • 875
  • 9
  • 24
  • 1
    the short answer is "you can't" -- the long answer is to instead use pylint from a pre-commit managed environment. using it from a `language: system` hook is the unsupported escape hatch and it's on you to make sure that your tools are available in that case – anthony sottile Feb 09 '23 at 14:19
  • @anthonysottile thanks. You drove the nails in the coffin :) As I mentioned pylint in the shell and from pre-commit work well. Shall just stop using Github desktop – Robert Alexander Feb 09 '23 at 14:55

1 Answers1

-2

pre-commit try to use a separate virtualenv, you need to tell it to use the local venv with something like this:

  - repo: local
    hooks:
      - id: pylint
        name: pylint
Pierre.Sassoulas
  • 3,733
  • 3
  • 33
  • 48
  • Thanks Pierre but pre-commit is already like this and works perfectly from the command line. It's GitHub desktop not finding pylint ... unfortunately comments are unformatted but this is the .pre-commit-config.yaml section: - repo: local hooks: - id: pylint name: pylint entry: pylint language: python types: [python] args: [--fail-under=8, --enable="W", --recursive=y, -rn,] – Robert Alexander Feb 09 '23 at 10:02
  • this is both not an answer and not a valid pre-commit configuration – anthony sottile Feb 09 '23 at 15:31