File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -euo pipefail
33
4- root= " $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.. " && pwd ) "
5- cd " $root "
6- dev_requirements= " $root /requirements-dev.txt "
4+ source " $( dirname " ${BASH_SOURCE[0]} " ) /ruff-common.sh "
5+ ruff_common_setup
6+ ruff_resolve_targets " $@ "
77
8- if ! command -v ruff > /dev/null 2>&1 ; then
9- echo " ruff not found; install with: pip install -r $dev_requirements " >&2
10- exit 1
11- fi
12-
13- targets=(" $@ " )
14- if [ " ${# targets[@]} " -eq 0 ]; then
15- targets=(" ." )
16- fi
17-
18- ruff check --fix " ${targets[@]} "
19- ruff format " ${targets[@]} "
8+ ruff check --fix " ${RUFF_TARGETS[@]} "
9+ ruff format " ${RUFF_TARGETS[@]} "
Original file line number Diff line number Diff line change 22set -euo pipefail
33
44# Matches the ruff job in .github/workflows/ci.yml (see also scripts/format).
5- root= " $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.. " && pwd ) "
6- cd " $root "
7- dev_requirements= " $root /requirements-dev.txt "
5+ source " $( dirname " ${BASH_SOURCE[0]} " ) /ruff-common.sh "
6+ ruff_common_setup
7+ ruff_resolve_targets " $@ "
88
9- if ! command -v ruff > /dev/null 2>&1 ; then
10- echo " ruff not found; install with: pip install -r $dev_requirements " >&2
11- exit 1
12- fi
13-
14- targets=(" $@ " )
15- if [ " ${# targets[@]} " -eq 0 ]; then
16- targets=(" ." )
17- fi
18-
19- ruff format --check " ${targets[@]} "
20- ruff check " ${targets[@]} "
9+ ruff format --check " ${RUFF_TARGETS[@]} "
10+ ruff check " ${RUFF_TARGETS[@]} "
Original file line number Diff line number Diff line change 1+ # Shared setup for scripts/lint and scripts/format.
2+ ruff_common_setup () {
3+ RUFF_ROOT=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd) "
4+ cd " $RUFF_ROOT "
5+
6+ if ! command -v ruff > /dev/null 2>&1 ; then
7+ echo " ruff not found; install with: pip install -r $RUFF_ROOT /requirements-dev.txt" >&2
8+ exit 1
9+ fi
10+ }
11+
12+ ruff_resolve_targets () {
13+ RUFF_TARGETS=(" $@ " )
14+ if [ " ${# RUFF_TARGETS[@]} " -eq 0 ]; then
15+ RUFF_TARGETS=(" ." )
16+ fi
17+ }
You can’t perform that action at this time.
0 commit comments