UMass-Rescue / UMass-Rescue/RescueBox
Lint CI and pre-commit enforce two different formatters (black vs ruff format)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6
- Forks
- 15
- Avg merge
- 14h 42m
- Merged PRs (30d)
- 7
Description
Hi — I'm looking at contributing and ran into this before I could open a PR, so I'd rather ask than guess which way you'd want it fixed.
Symptom
black --check . fails on a clean checkout of main (4b52398), so the Lint workflow is red on every PR regardless of what the PR changes.
$ pip install black==24.10.0 ruff==0.7.1 # the versions lint.yml pins
$ black --check .
13 files would be reformatted, 371 files would be left unchanged.
ruff check passes cleanly — it's only the format check that fails.
Cause
The two formatters disagree, and each rejects the other's output:
.pre-commit-config.yamlrunsruff-format(ruff v0.7.1).github/workflows/lint.ymlrunsblack --check .(black 24.10.0)
Taking src/rb-lib/rb/lib/utils.py and formatting it each way:
$ ruff format a.py && black --check a.py
1 file would be reformatted.
$ black b.py && ruff format --check b.py
Would reformat: b.py
The divergence is how each wraps assert cond, "long message" — ruff 0.7 implements the style black adopted later in preview:
# ruff format
assert issubclass(input_type_hint, FileInput), (
f"For key {key}, the input type is InputType.FILE, ..."
)
# black 24.10
assert issubclass(
input_type_hint, FileInput
), f"For key {key}, the input type is InputType.FILE, ..."
Repo-wide: ruff format --check . reports 64 files, black --check . reports 13.
Why it matters for contributors
Anyone who installs pre-commit as configured gets their commit auto-formatted by ruff into a shape the Lint job then rejects.
The question
Which formatter do you want to keep?
I'm happy to do the work either direction, in two commits so the reviewable part stays small:
- the config change — a few lines in
lint.ymland/or.pre-commit-config.yaml, plus a[tool.ruff]block in the rootpyproject.tomlpinning line-length and target-version so the two can't drift apart again - the mechanical reformat pass
Two smaller things I noticed while in there — happy to fold in or leave alone:
lint.ymluses Python 3.11 whiletest.ymluses 3.12- the root
pyproject.tomlhas no[tool.ruff]section, soruff checkruns its default rule set only (E4/E7/E9/F)
Whichever direction you pick, the reformat commit will conflict with any long-lived branch, so I'm glad to time it for whenever is least disruptive.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with .github/workflows/lint.yml, .pre-commit-config.yaml, and the root pyproject.toml to compare the formatter commands and available configuration. Run the reported black and ruff format checks, then confirm the chosen formatter and scope with maintainers. Done means pre-commit and the Lint workflow enforce the same formatting and pass on the repository.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ci-cd, tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100