2# Lint and format Python files with `ruff`.
4# This will format files in the working directory by default, or you
5# can supply one or more paths for it to check.
11# Work out which directory to run in:
13# * if no argument is specified, use the current working directory
14# * if one or more directories are specified, use those
16# TODO: What if somebody passes a custom directory and `--fix`?
20elif [[ "$#" = "1" && "$1" = "--fix" ]]
29# Work out which instance of ruff to use
31# If we're in a virtualenv which has ruff installed, we use the locally
34# If not, we use the `ruff` from my ~/repos/scripts virtualenv.
35if which ruff >/dev/null
39 RUFF=~/repos/scripts/.venv/bin/ruff
43print_info "-> ruff format"
44bash -c "$RUFF format $ROOT"
48print_info "-> ruff check --fix"
49bash -c "$RUFF check $ROOT --fix"