Format the tree with ruff, and gate it in CI - #38
Merged
Merged
Conversation
Runs `ruff format` over the whole repo: 41 of 46 files. The five that were already formatted are the ones somebody had run a formatter over before. Settings are pinned in pyproject.toml rather than left to ruff's defaults, so that a change upstream is a deliberate edit here and not a surprise repo-wide reformat. line-length 88 matches the already-formatted files. skip-magic-trailing-comma is on. The trailing commas in this tree come from a habit of writing `[8, ]`, not from a wish to keep those calls exploded; without it, `smoothness_kernel([params[i], ], df[i])` becomes eight lines. Markdown is excluded. Ruff formats the python blocks inside it, which in the README splits a one-line call across three because a trailing comment pushes it past the limit. ruff is pinned to 0.16.x, since it is now a gate and a formatting change in a new release would turn that gate red on a tree nobody touched. This changes no behaviour. 36 of 44 files parse to a byte-identical AST; the other 8 have identical structure and differ only in whitespace inside docstrings. The suite is 69 passed either way, and `ruff check` finds the same 243 lint issues before and after, so the formatter neither fixed nor introduced any.
Merged
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.
ruff formatover the whole repo — 41 of 46 files. The five already formattedare the ones somebody had run a formatter over at some point, which is why the
tree currently has two styles in it.
Nothing here changes behaviour, and the diff is large enough that saying so
is not worth much without a check. See "Proof" below.
The settings, and why they are not the defaults
Pinned in
pyproject.tomlrather than left implicit, so a change to ruff's owndefaults is a deliberate edit here rather than a repo-wide reformat nobody asked
for.
line-length = 88— ruff's default, and what the already-formatted filesuse. 100 and 120 were about the same diff size (2871 and 2611 changed lines
against 2975), so this is not the axis that matters.
skip-magic-trailing-comma = true— this one is a real choice. Ruff, likeblack, treats a trailing comma as "keep this exploded". The trailing commas in
this tree are a habit of writing
[8, ]and[params[i], ], not a request, andrespecting them produces:
against
isort.split-on-trailing-comma = falsecomes with it; ruff warns if theydisagree.
extend-exclude = ["*.md"]— ruff formats python blocks inside markdown.In the README that turns
into a three-line call, because the trailing comment pushes it past 88. Worse
documentation for the sake of a limit the block is not compiled under.
ruff>=0.16,<0.17in the dev group. It is a CI gate now, and an unpinnedformatter means a release can turn that gate red on a tree nobody touched.
Proof that it changes nothing
Every
.pyfile was parsed before and after and the ASTs compared:ast.dump.constant blanked out gives an exact match — and differ only in whitespace
inside docstrings, which is the formatter stripping trailing spaces and
reindenting. For all of them,
"".join(old.split()) == "".join(new.split()).Plus: the suite is
69 passedbefore and after, andruff checkreports thesame 243 findings both ways, so the formatter neither fixed nor introduced a
single lint issue.
CI
Adds a
formatjob runningruff format --check ..It does not add
ruff check. There are 243 lint findings in the tree, and agate that passes because it is not looking is worth nothing. That job goes in
with the change that clears them, which is the next PR — and it is a much less
mechanical one than this: 26
F401unused imports where some are deliberatere-exports through
import *, 25 unused unpacked variables, 7 bareexcept:.Worth keeping separate from a whitespace diff.