Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ jobs:
python-version: "3.11"
- name: Install ruff
run: pip install --no-cache-dir -r requirements-dev.txt
- name: Run ruff format check
run: ruff format --check .
- name: Run ruff lint check
if: success() || failure()
run: ruff check .
- name: Run ruff (format + lint check)
run: ./scripts/ruff check
ddprof:
uses: ./.github/workflows/test.yml
with:
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Optional git hooks for Python scenario files (same checks as CI — see scripts/lint).
# Optional git hooks for Python scenario files (same checks as CI — see scripts/ruff).
# Setup: pip install -r requirements-dev.txt pre-commit && pre-commit install
# On Datadog laptops with global core.hooksPath, use ./scripts/lint instead of pre-commit install.
# On Datadog laptops with global core.hooksPath, run ./scripts/ruff check manually instead.
repos:
- repo: local
hooks:
- id: ruff
name: ruff (scripts/lint)
entry: scripts/lint
name: ruff (scripts/ruff check)
entry: scripts/ruff check
language: system
types: [python]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ pip install -r requirements-dev.txt
```

```sh
./scripts/lint # check (matches the ci.yml ruff job)
./scripts/format # auto-fix formatting and lint
./scripts/ruff check # what CI runs (format --check + lint)
./scripts/ruff fix # auto-fix formatting and lint in place
```

Optional git hooks (skip on Datadog laptops that use global `core.hooksPath` — run `./scripts/lint` manually instead):
Optional git hooks (skip on Datadog laptops that use global `core.hooksPath` — run `./scripts/ruff check` manually instead):

```sh
pip install pre-commit
Expand Down
10 changes: 2 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,13 @@ select = [
"RUF", # Ruff-specific rules
]
ignore = [
"D203", # one-blank-line-before-class (conflicts with D211)
"D213", # multi-line-summary-second-line (conflicts with D212)
"T201", # print statement used
"PLR2004", # constant variable
]

[tool.ruff.lint.per-file-ignores]
"**/__init__.py" = ["D104"] # missing docstring in public package
"**/test_*.py" = ["S101", "D"] # allow assert in tests, skip docstrings
"**/tests/**/*.py" = ["S101", "D"] # allow assert in tests, skip docstrings

[tool.ruff.lint.pydocstyle]
convention = "google"
"**/test_*.py" = ["S101"] # allow assert in tests
"**/tests/**/*.py" = ["S101"] # allow assert in tests

[tool.ruff.lint.mccabe]
max-complexity = 10
Expand Down
9 changes: 0 additions & 9 deletions scripts/format

This file was deleted.

10 changes: 0 additions & 10 deletions scripts/lint

This file was deleted.

37 changes: 37 additions & 0 deletions scripts/ruff
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Python lint/format for scenario workloads. Uses the ruff pinned in requirements-dev.txt.
#
# scripts/ruff check [paths...] # what CI runs (see .github/workflows/ci.yml)
# scripts/ruff fix [paths...] # auto-fix lint + format in place
#
# With no paths, runs on the whole repo (".").
set -euo pipefail

cd "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

if ! command -v ruff >/dev/null 2>&1; then
echo "ruff not found; install with: pip install -r requirements-dev.txt" >&2
exit 1
fi

mode="${1:-check}"
[ $# -gt 0 ] && shift
targets=("$@")
[ ${#targets[@]} -eq 0 ] && targets=(".")

case "$mode" in
check)
ruff format --check "${targets[@]}"
ruff check "${targets[@]}"
;;
fix)
# `ruff check --fix` exits non-zero when unfixable lints remain; `|| true` keeps
# `set -e` from aborting before we format. Fix first, format last, so output converges.
ruff check --fix "${targets[@]}" || true
ruff format "${targets[@]}"
;;
*)
echo "usage: scripts/ruff {check|fix} [paths...]" >&2
exit 2
;;
esac
17 changes: 0 additions & 17 deletions scripts/ruff-common.sh

This file was deleted.

Loading