Skip to content

Commit f3e1403

Browse files
chore: add scripts/lint and scripts/format for local ruff checks
Mirror dd-trace-py's scripts/lint workflow without git hooks — works with Datadog global core.hooksPath. Matches the pinned CI ruff job.
1 parent 000858b commit f3e1403

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Lightweight Python formatting/lint for scenario workloads. Matches the ruff job in ci.yml.
2-
# Install: pip install pre-commit && pre-commit install
2+
# Local: ./scripts/lint (check) or ./scripts/format (auto-fix)
3+
# Optional hooks (skipped when core.hooksPath is set): pip install pre-commit && pre-commit install
34
repos:
45
- repo: https://github.com/astral-sh/ruff-pre-commit
56
rev: v0.15.5

scripts/format

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
cd "$root"
6+
7+
if ! command -v ruff >/dev/null 2>&1; then
8+
echo "ruff not found; install with: pip install ruff==0.15.5" >&2
9+
exit 1
10+
fi
11+
12+
targets=("$@")
13+
if [ "${#targets[@]}" -eq 0 ]; then
14+
targets=(".")
15+
fi
16+
17+
ruff format "${targets[@]}"
18+
ruff check --fix "${targets[@]}"

scripts/lint

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# 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+
8+
if ! command -v ruff >/dev/null 2>&1; then
9+
echo "ruff not found; install with: pip install ruff==0.15.5" >&2
10+
exit 1
11+
fi
12+
13+
targets=("$@")
14+
if [ "${#targets[@]}" -eq 0 ]; then
15+
targets=(".")
16+
fi
17+
18+
ruff format --check "${targets[@]}"
19+
ruff check "${targets[@]}"

0 commit comments

Comments
 (0)