Skip to content

Commit

Permalink
Update pre-commit (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggravlingen authored Mar 9, 2024
1 parent 62934ed commit 2ca770d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
hooks:
- id: mypy
name: mypy
entry: ./script/run-pre-commit.sh mypy
entry: script/run-in-env.sh mypy
language: script
types: [python]
require_serial: true
Expand Down
27 changes: 27 additions & 0 deletions script/run-in-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env sh
# From https://github.com/home-assistant/core/blob/dev/script/run-in-env.sh
set -eu

# Used in venv activate script.
# Would be an error if undefined.
OSTYPE="${OSTYPE-}"

# Activate pyenv and virtualenv if present, then run the specified command

# pyenv, pyenv-virtualenv
if [ -s .python-version ]; then
PYENV_VERSION=$(head -n 1 .python-version)
export PYENV_VERSION
fi

# other common virtualenvs
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 "$@"

0 comments on commit 2ca770d

Please sign in to comment.