From f91c31f093142d11225e1ca3d4fa79817a719490 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 16 May 2024 13:47:56 +1200 Subject: [PATCH] [core] Fix running pylint via pre-commit from GUI apps (#6754) --- .pre-commit-config.yaml | 4 ++-- script/run-in-env.sh | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100755 script/run-in-env.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ce226846e3..418716e4f4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,6 +44,6 @@ repos: hooks: - id: pylint name: pylint - entry: pylint - language: system + entry: script/run-in-env.sh pylint + language: script types: [python] diff --git a/script/run-in-env.sh b/script/run-in-env.sh new file mode 100755 index 0000000000..2e05fe1d17 --- /dev/null +++ b/script/run-in-env.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env sh +set -eu + +my_path=$(git rev-parse --show-toplevel) + +for venv in venv .venv .; do + if [ -f "${my_path}/${venv}/bin/activate" ]; then + . "${my_path}/${venv}/bin/activate" + break + fi +done + +exec "$@"