11
votes

When using https://pre-commit.com with VSCode hooks that depend on packages installed in a Python venv. In pre-commit on can specify to use "system" as environment. This works great from the terminal with desired venv active.

However using the integrated source control it seems that global interpeter is accessed and thus required packages are not available.

Is there a workaround here? As for now I specify the entrypoint "path/to/bin/python -m package" in pre-commit config. However I do think that also the integrated source control should respect at least the selected interpeter.

Any thoughts?

1

1 Answers

1
votes

VSCode seems to choose willy-nilly what it respects and what it doesn't. I have the same situation - committing on the integrated terminal works fine; doing it from the Source Control sidebar gives me a "Python can't be found" message (which only appeared after installing a pre-commit hook).

My guess is you'll have to, by trial and error, install pre-commit in every Python installation in your system until you find which one the sidebar is invoking.