Skip to content

Pre-commit: add ruff and enforce all hooks in CI - #343

Open
abhirajadhikary06 wants to merge 1 commit into
ArcadeData:mainfrom
abhirajadhikary06:precommit-ruff-270
Open

abhirajadhikary06 wants to merge 1 commit into
ArcadeData:mainfrom
abhirajadhikary06:precommit-ruff-270

Conversation

@abhirajadhikary06

Copy link
Copy Markdown

What does this PR do?

Enforces pre-commit in CI and adds ruff as the Python linter (#270). This is commit 1 of three — configuration only, touching no source file, so it does not conflict with the open 26.11.1.post1 PRs.

  • pyproject.toml: [tool.ruff] with default rules E4/E7/E9/F at line length 88 (Black's default; E501 is intentionally not enabled, so the lines Black leaves long are not flagged).
  • .pre-commit-config.yaml: adds ruff-check (check only), the basic hygiene hooks (trailing whitespace, end-of-file, merge-conflict markers, large files, private keys, check-yaml/toml/json/xml), prettier (Java, XML, Markdown, JSON; printWidth 160 for Java/XML, prose not hard-wrapped), shellcheck, and hadolint. Keeps black, isort, shfmt, pretty-format-yaml, actionlint.
  • .prettierrc.json: printWidth 160 for *.java/*.xml, proseWrap: preserve.
  • .github/workflows/pre-commit.yml: a CI job running uvx pre-commit run --all-files on every pull request and push to main.
  • CONTRIBUTING.md: documents uvx pre-commit install and the Docker note for shellcheck/hadolint.

Related issues

Closes #270 .

Performance changes

None — configuration only.

Docs

CONTRIBUTING.md (the Pre-commit section). No README.md or docs/ change needed for config.

Checklist

  • A regression test fails on the old code and passes on the new — N/A, no source change.
  • The test suite that the change can affect passes — N/A, no source change.
  • uvx pre-commit run --files <changed files> passes (run with SKIP=prettier,shellcheck,hadolint-docker,no-old-package-name: the prettier reformat is commit 3, the docker/python3 hooks are Linux-CI only).

Draft until release/26.11.1 merges to main. The Pre-commit CI job is expected to fail on the draft: ruff finds the 63 existing findings and prettier wants its first reformat. Commits 2 (ruff fixes) and 3 (prettier reformat) are added after the merge, each in its own commit; the PR then goes ready-for-review and the job passes.

Config only (commit 1 of ArcadeData#270): add ruff (default rules E4/E7/E9/F, line length 88), the hygiene/prettier/shellcheck/hadolint hooks, the CI job that runs uvx pre-commit run --all-files, and the install instructions in CONTRIBUTING.md. The 63 ruff fixes and the first prettier reformat land in separate commits after release/26.11.1 merges to main.
@abhirajadhikary06

Copy link
Copy Markdown
Author

@tae898 — opening this as a draft per your timing request.

This is commit 1 only: configuration that touches no source file, so it shouldn't conflict with the open 26.11.1.post1 PRs.

  • pyproject.toml — [tool.ruff] (default rules E4/E7/E9/F, line length 88)
  • .pre-commit-config.yaml — ruff-check, the hygiene hooks, prettier (Java/XML/Markdown/JSON), shellcheck, hadolint
  • .prettierrc.json — printWidth 160 for *.java/*.xml, proseWrap preserve
  • .github/workflows/pre-commit.yml — the uvx pre-commit run --all-files job on PR + push
  • CONTRIBUTING.md — uvx pre-commit install + the Docker note

A couple of notes on choices, happy to change any:

  • Ruff runs check-only (no --fix), so fixes land in their own commit; black/isort stay the formatters.
  • For the 8 benign F811 fixture-shadowings in tests/, I used a tests/** per-file-ignores in ruff config. If you'd rather have inline # noqa: F811 in commit 2, I'll drop the ignore.
  • Prettier uses types_or (OR) rather than upstream's types: [java, xml], since types is AND and would match no files.
  • shellcheck and hadolint run as docker_image hooks (Docker pulls the images automatically, both locally and in CI).

As expected on the draft, the Pre-commit CI job fails — ruff finds the 63 findings and prettier wants its first reformat.

Commits 2 (ruff fixes) and 3 (prettier reformat) will be added after release/26.11.1 merges into main, each in its own commit; I'll mark it ready-for-review then. Please comment here when that merge has happened. Thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce pre-commit in CI and add a linter (ruff defaults: 63 findings on main); line length stays 88

2 participants