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?
If your workspace is on your local machine, you can enable Git source control by creating a Git repository with the Initialize Repository command. When VS Code doesn't detect an existing Git repository, the Source Control view will give you the options to Initialize Repository or Publish to GitHub.
Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.
Terminal Basics. Visual Studio Code includes a fully-featured integrated terminal that conveniently starts at the root of your workspace. It provides integration with the editor to support features like links and error detection. To open the terminal: Use the Ctrl+` keyboard shortcut with the backtick character.
Quick tip if you want to skip the pre-commit validations and quickly want to get a commit out there. To get your commit through without running that pre-commit hook, use the --no-verify option. Voila, without pre-commit hooks running!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With