Skip to content

Commit

Permalink
presubmit: allow using existing virtual environment (#827)
Browse files Browse the repository at this point in the history
I often run from a virtual environment that is not located in
$GITROOT/.venv. This change enables using either or with presubmit.

---------

Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski authored Mar 1, 2025
1 parent e42beef commit f08dd92
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/helper/presubmit
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ GIT_ROOT=$(git rev-parse --show-toplevel)

# Disable shellcheck false warning as it assumes incorrect path of `activate`.
# shellcheck disable=SC1091
source "$GIT_ROOT/.venv/bin/activate"

if [[ -z "${VIRTUAL_ENV:-""}" ]]; then
source "$GIT_ROOT/.venv/bin/activate"
fi

# Always use the latest Pyright.
export PYRIGHT_PYTHON_FORCE_VERSION=latest
Expand Down Expand Up @@ -35,9 +38,7 @@ done
# Type Check and lint all Python code.
pyright "$GIT_ROOT" \
--project="$GIT_ROOT/.pyrightconfig.json" \
--venvpath="$GIT_ROOT/.venv"


--venvpath="$VIRTUAL_ENV"

# Check and remove trailing spaces.
## Exclude Markdown which allows trailing spaces.
Expand Down

0 comments on commit f08dd92

Please sign in to comment.