[core] Fix running pylint via pre-commit from GUI apps (#6754)

This commit is contained in:
Jesse Hills 2024-05-16 13:47:56 +12:00 committed by GitHub
parent a27c05483c
commit f91c31f093
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View File

@ -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]

13
script/run-in-env.sh Executable file
View File

@ -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 "$@"