File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030 python-version : " 3.11"
3131 - name : Install ruff
3232 run : pip install --no-cache-dir -r requirements-dev.txt
33- - name : Run ruff format check
34- run : ruff format --check .
35- - name : Run ruff lint check
36- if : success() || failure()
37- run : ruff check .
33+ - name : Run ruff (format + lint check)
34+ run : ./scripts/ruff check
3835 ddprof :
3936 uses : ./.github/workflows/test.yml
4037 with :
Original file line number Diff line number Diff line change 1- # Optional git hooks for Python scenario files (same checks as CI — see scripts/lint ).
1+ # Optional git hooks for Python scenario files (same checks as CI — see scripts/ruff ).
22# Setup: pip install -r requirements-dev.txt pre-commit && pre-commit install
3- # On Datadog laptops with global core.hooksPath, use ./scripts/lint instead of pre-commit install .
3+ # On Datadog laptops with global core.hooksPath, run ./scripts/ruff check manually instead .
44repos :
55 - repo : local
66 hooks :
77 - id : ruff
8- name : ruff (scripts/lint )
9- entry : scripts/lint
8+ name : ruff (scripts/ruff check )
9+ entry : scripts/ruff check
1010 language : system
1111 types : [python]
Original file line number Diff line number Diff line change @@ -19,11 +19,11 @@ pip install -r requirements-dev.txt
1919```
2020
2121``` sh
22- ./scripts/lint # check (matches the ci.yml ruff job )
23- ./scripts/format # auto-fix formatting and lint
22+ ./scripts/ruff check # what CI runs (format -- check + lint )
23+ ./scripts/ruff fix # auto-fix formatting and lint in place
2424```
2525
26- Optional git hooks (skip on Datadog laptops that use global ` core.hooksPath ` — run ` ./scripts/lint ` manually instead):
26+ Optional git hooks (skip on Datadog laptops that use global ` core.hooksPath ` — run ` ./scripts/ruff check ` manually instead):
2727
2828``` sh
2929pip install pre-commit
Original file line number Diff line number Diff line change @@ -40,19 +40,13 @@ select = [
4040 " RUF" , # Ruff-specific rules
4141]
4242ignore = [
43- " D203" , # one-blank-line-before-class (conflicts with D211)
44- " D213" , # multi-line-summary-second-line (conflicts with D212)
4543 " T201" , # print statement used
4644 " PLR2004" , # constant variable
4745]
4846
4947[tool .ruff .lint .per-file-ignores ]
50- "**/__init__.py" = [" D104" ] # missing docstring in public package
51- "**/test_*.py" = [" S101" , " D" ] # allow assert in tests, skip docstrings
52- "**/tests/**/*.py" = [" S101" , " D" ] # allow assert in tests, skip docstrings
53-
54- [tool .ruff .lint .pydocstyle ]
55- convention = " google"
48+ "**/test_*.py" = [" S101" ] # allow assert in tests
49+ "**/tests/**/*.py" = [" S101" ] # allow assert in tests
5650
5751[tool .ruff .lint .mccabe ]
5852max-complexity = 10
Load diff This file was deleted.
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # Python lint/format for scenario workloads. Uses the ruff pinned in requirements-dev.txt.
3+ #
4+ # scripts/ruff check [paths...] # what CI runs (see .github/workflows/ci.yml)
5+ # scripts/ruff fix [paths...] # auto-fix lint + format in place
6+ #
7+ # With no paths, runs on the whole repo (".").
8+ set -euo pipefail
9+
10+ cd " $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd) "
11+
12+ if ! command -v ruff > /dev/null 2>&1 ; then
13+ echo " ruff not found; install with: pip install -r requirements-dev.txt" >&2
14+ exit 1
15+ fi
16+
17+ mode=" ${1:- check} "
18+ [ $# -gt 0 ] && shift
19+ targets=(" $@ " )
20+ [ ${# targets[@]} -eq 0 ] && targets=(" ." )
21+
22+ case " $mode " in
23+ check)
24+ ruff format --check " ${targets[@]} "
25+ ruff check " ${targets[@]} "
26+ ;;
27+ fix)
28+ # `ruff check --fix` exits non-zero when unfixable lints remain; `|| true` keeps
29+ # `set -e` from aborting before we format. Fix first, format last, so output converges.
30+ ruff check --fix " ${targets[@]} " || true
31+ ruff format " ${targets[@]} "
32+ ;;
33+ * )
34+ echo " usage: scripts/ruff {check|fix} [paths...]" >&2
35+ exit 2
36+ ;;
37+ esac
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments