chore: replace black with ruff format - #766
Merged
Merged
Conversation
joshmarkovic
marked this pull request as ready for review
July 27, 2026 02:36
Completes the toolchain consolidation started in dbt-msft#707, which moved linting to Ruff. The two black hooks are replaced by ruff-format hooks in the existing astral-sh/ruff-pre-commit block, so lint and format share one repo, one version pin, and one [tool.ruff] config block. No new configuration: ruff format reads line-length and target-version from pyproject.toml. Makefile: the black target becomes format; the test target checks formatting with ruff-format-check. Reformats 12 files. All changes are cosmetic: joined implicit string concatenations that now fit in 99 columns, assert message reflow, decorator argument wrapping, and a blank line after a class header. Closes dbt-msft#711
Adds the previous commit to .git-blame-ignore-revs so the cosmetic reformat does not shadow the real authors of those lines. Both git blame --ignore-revs-file and GitHub's blame view honour the file.
axellpadilla
force-pushed
the
jm/ruff-format
branch
from
July 27, 2026 02:39
18fe2fb to
f5372c6
Compare
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.
Summary
Closes #711. This finishes what #707 started. That PR moved linting to Ruff but left
blackin place as the formatter. This PR swapsblackforruff format, so one tool and one config block now cover both jobs.The two
blackhooks are gone. In their place are tworuff-formathooks inside theastral-sh/ruff-pre-commitblock we already have, matching the pattern of the existingruff-checkhooks: one that fixes on commit, one manual alias namedruff-format-checkthat runs--check --diff.No new configuration.
ruff formatreadsline-length = 99andtarget-version = "py311"from the[tool.ruff]block that #707 added.Why
blackpulls inclick,mypy-extensions,packaging,pathspec,platformdirs, andpytokens. Dropping it removes one more consumer ofpathspec, the package behind theoverride-dependenciesworkaround inpyproject.toml. That workaround still has to stay, but this is one less thing depending on it.--checkoverdbt/andtests/is roughly 0.06s forruff formatagainst 0.27s forblack. Small in absolute terms, but it adds up across pre-commit and CI.What changed in the code
Twelve files, all cosmetic:
dbt/adapters/sqlserver/sqlserver_relation.py. Two implicit f-string concatenations get joined onto one line now that they fit in 99 columns. Same string either way..github/scripts/verify_version.py. Same thing, one joined concatenation. This one was not in the issue write-up, which only measureddbt/andtests/. Pre-commit runs over every tracked Python file, so it turned up.tests/functional/. A blank line removed after a class header,assert cond, (msg)reflowed, decorator arguments wrapped, andf"{ limit }"normalised tof"{limit}". Whitespace inside f-string braces is not part of the output, so that last one is a no-op at runtime.make blackbecomesmake format.make testchecks formatting throughruff-format-check.The reformat commit is listed in
.git-blame-ignore-revs, alongside the two entries already there. GitHub's blame view honours that file automatically. Worth keeping the two commits separate on merge, since a squash would leave the recorded SHA pointing at nothing. Git tolerates an unresolvable entry silently, so nothing breaks either way, but the entry would stop doing its job.Verification
pre-commit run --all-filespasses every hook: ruff check, ruff format, mypy, yamllint, and the pre-commit-hooks set.mypy 2.1.0clean on 17 source files.Trade-offs
.git-blame-ignore-revsentry.dbt-labs/dbt-adapters, which still usesblack. Given how close ruff's output is, this should not matter in practice.ruff-format-check, notblack-check. Anyone with a local script or muscle memory formake blackwill need to switch tomake format.Checklist
pre-commit run --all-filespasses.git-blame-ignore-revs