Skip to content

Commit

Permalink
style(maintenance_scripts: lint): improve formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
actionless committed Mar 15, 2024
1 parent 401cbd2 commit 5aaa74b
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions maintenance_scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail

PYTHON=python3
script_dir=$(readlink -e "$(dirname "${0}")")
APP_DIR="$(readlink -e "${script_dir}"/..)"


FIX_MODE=0
Expand All @@ -21,6 +22,8 @@ if [[ -n "$*" ]] ; then
fi


PYTHON=python3

TARGETS=(
'pikaur'
'pikaur_test'
Expand All @@ -32,25 +35,33 @@ if [[ -n "${1:-}" ]] ; then
fi


script_dir=$(readlink -e "$(dirname "${0}")")
APP_DIR="$(readlink -e "${script_dir}"/..)"
install_ruff() {
if [[ ! -f "${APP_DIR}/env/bin/activate" ]] ; then
"$PYTHON" -m venv "${APP_DIR}/env" --system-site-packages
# shellcheck disable=SC1091
. "${APP_DIR}/env/bin/activate"
"$PYTHON" -m pip install ruff --upgrade
deactivate
fi
}
RUFF="${APP_DIR}/env/bin/ruff"

export PYTHONWARNINGS='ignore,error:::pikaur[.*],error:::pikaur_test[.*]'

echo Python compile...
"$PYTHON" -O -m compileall "${TARGETS[@]}" \
| (\
grep -v -e '^Listing' -e '^Compiling' || true \
)

echo Python import...
#"$PYTHON" -c "import pikaur"
"$PYTHON" -c "import pikaur.main"

if [[ "$FIX_MODE" -eq 1 ]] ; then
"$RUFF" check --unsafe-fixes --fix "${TARGETS[@]}"
else
export PYTHONWARNINGS='ignore,error:::pikaur[.*],error:::pikaur_test[.*]'


echo Python compile...
"$PYTHON" -O -m compileall "${TARGETS[@]}" \
| (\
grep -v -e '^Listing' -e '^Compiling' || true \
)

echo Python import...
#"$PYTHON" -c "import pikaur"
"$PYTHON" -c "import pikaur.main"

echo Checking for non-Final globals...
./maintenance_scripts/get_non_final_expressions.sh
Expand All @@ -71,13 +82,7 @@ else
| awk '{print $1;}' \
| sort)
echo Ruff...
if [[ ! -f "${APP_DIR}/env/bin/activate" ]] ; then
"$PYTHON" -m venv "${APP_DIR}/env" --system-site-packages
# shellcheck disable=SC1091
. "${APP_DIR}/env/bin/activate"
"$PYTHON" -m pip install ruff --upgrade
deactivate
fi
install_ruff
"$RUFF" check "${TARGETS[@]}"

echo Flake8...
Expand Down

0 comments on commit 5aaa74b

Please sign in to comment.