chore(ci): pin ruff and add pre-commit hooks (PROF-15511) - #174
Merged
Conversation
Fixes ruff format --check CI failure (extra blank line in code block).
Pin CI ruff to match pyproject.toml expectations and add a minimal pre-commit config (ruff-format + ruff --fix) so local runs match CI.
3 tasks
Mirror dd-trace-py's scripts/lint workflow without git hooks — works with Datadog global core.hooksPath. Matches the pinned CI ruff job.
There was a problem hiding this comment.
Pull request overview
This PR improves repo-wide Python linting/formatting consistency by pinning Ruff in CI and adding lightweight contributor tooling (pre-commit + convenience scripts) to reduce local/CI drift.
Changes:
- Pin
ruff==0.15.5in the GitHub Actions CI workflow. - Add
.pre-commit-config.yamlwith Ruff formatting and autofix hooks. - Add
scripts/lintandscripts/formathelper scripts; apply a small Ruff-format change in a scenario README.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/lint |
Adds a local wrapper that runs ruff format --check and ruff check on provided targets. |
scripts/format |
Adds a local wrapper intended to auto-fix via Ruff formatting and lint fixes. |
scenarios/python_safe_point_bias_3.11/README.md |
Applies formatting-only adjustment in an embedded Python snippet. |
.pre-commit-config.yaml |
Introduces optional pre-commit hooks for Ruff formatting and autofix. |
.github/workflows/ci.yml |
Pins the Ruff version installed in CI to avoid drift. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ruff check --fix can rewrite imports; formatting last avoids leaving files unformatted after a single scripts/format or pre-commit run.
- Add requirements-dev.txt as the only ruff version pin - CI and scripts reference it; local pre-commit hook runs scripts/lint - Document Python lint setup in README
vlad-scherbich
marked this pull request as ready for review
July 27, 2026 22:06
r1viollet
added a commit
that referenced
this pull request
Jul 28, 2026
Follow-up to #174 based on review feedback: - Keep the existing ruff ruleset (per review, the strict set is fine). - Remove only dead config: the D-rule ignores/per-file-ignores and the pydocstyle section referenced rules that were never in select, so they had no effect. No change to what is actually enforced. - Collapse scripts/lint + scripts/format + scripts/ruff-common.sh into a single 'scripts/ruff {check|fix}'. - Fix scripts/ruff fix: 'ruff check --fix' exits non-zero on remaining unfixable lints, which under 'set -e' aborted before formatting ran, leaving files unformatted. Now formatting always runs. - Point CI, README, and pre-commit at the single script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Next: #165
Summary
Started implementing pre-commit hooks for automated lints and formatting fixes before the issues hit CI in PR. Cheap prevention of stuck PRs needing CI reruns.
Changes
requirements-dev.txt— single pin forruff==0.15.5(CI, scripts, install docs)pip install -r requirements-dev.txt;ruff format --check+ruff check(unchanged behavior, pinned version)scripts/lint/scripts/format— local wrappers matching CI vs auto-fix; shared setup inscripts/ruff-common.shruff check --fix→ruff format) so one./scripts/formatrun converges.pre-commit-config.yaml— optional local hook callingscripts/lint(language: system; no second ruff version pin viaastral-sh/ruff-pre-commit)README.md— Python lint setup (pip install -r requirements-dev.txt, scripts, optional pre-commit)ruff formatfix inscenarios/python_safe_point_bias_3.11/README.mdLocal workflow