Skip to content

Format main to its own pinned hook, so pre-commit autofix can land again - #11019

Merged
danielhanchen merged 1 commit into
mainfrom
ci/format-main-to-its-own-hook
Sep 15, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci/format-main-to-its-own-hook

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

main is not formatted the way its own hook formats

Running scripts/run_ruff_format.py with the pinned ruff 0.6.9 over every file the hook selects changes three files on 52fb7b035:

file arrived in
studio/backend/tests/test_diffusers_prewarm.py #10989
studio/backend/utils/torch_warmup.py #10989
tests/python/test_amd_extras_contract.py #7536

Both merged within the last hour with pre-commit.ci - pr in ERROR.

Why this is not just tidiness

It takes pre-commit.ci's autofix down for every other pull request.

The hook runs against the PR merged with main, so every open PR's tree now carries these three files needing reformatting. The autofix patch is computed over that tree and then cannot be applied to a head that does not carry main's copy of them. Three PRs are currently red on exactly this, each with a one-or-two-line formatting delta it cannot self-heal, all reporting the same thing:

a conflict occurred when applying fixes to the pr. try pulling the upstream branch

The loop is self-sustaining. Unformatted code on main disables the autofix, and PRs then merge red because nothing can push the fix for them, which is how the second of the two offending merges got in after the first.

Is the formatter right, or is the code?

The formatter, on two counts.

It is pinned in .pre-commit-config.yaml (ruff==0.6.9), so it is the repo's own definition of formatted, and scripts/run_ruff_format.py refuses to run under any other version rather than producing a different answer.

And it is idempotent. Re-running it over these files changes nothing on the second or third pass, so this is a fixed point and not one step of a moving target. That mattered, because one hunk looks wrong at a glance:

-        def find_spec(self, name, path = None, target = None):
+        def find_spec(
+            self,
+            name,
+            path = None,
+            target = None,
+        ):

Ruff would not explode a signature that short. The hook rewrites path=None to path = None first, and the longer line then no longer fits. Intended behaviour of the kwarg-spacing wrapper, and stable.

Verification

  • comment_tools.py check --strict-ext: 3/3 OK, so every AST is unchanged and this is whitespace only.
  • studio/backend/tests/test_diffusers_prewarm.py: 28 passed.
  • tests/python/test_amd_extras_contract.py: 10 passed.
  • Re-running the hook over the whole tree afterwards touches these three files and nothing else, so the tree is back at the hook's fixed point.

main is not formatted the way its own pre-commit hook formats. Running
scripts/run_ruff_format.py with the pinned ruff 0.6.9 over every file the hook
selects changes three files on 52fb7b0:

    studio/backend/tests/test_diffusers_prewarm.py   (#10989)
    studio/backend/utils/torch_warmup.py             (#10989)
    tests/python/test_amd_extras_contract.py         (#7536)

Both of those PRs merged in the last hour with `pre-commit.ci - pr` in ERROR.

That is not only a tidiness problem, because it takes pre-commit.ci's autofix
down for every OTHER pull request. The hook runs against the PR merged with
main, so every PR's tree now contains these three files needing reformatting;
the autofix patch is computed over them and then cannot be applied to a head
that does not carry main's copy. Three PRs are red on exactly that, each with a
one-or-two-line formatting delta it cannot self-heal, all reporting:

    a conflict occurred when applying fixes to the pr.
    try pulling the upstream branch

So this is self-sustaining: unformatted code on main disables the autofix, and
PRs then merge red because nothing can push the fix for them.

The formatter, not the code, is the thing to trust here: it is pinned in
.pre-commit-config.yaml, and it is idempotent. Running it again over these files
changes nothing on the second or third pass, so this is a fixed point rather
than one step of a moving target. One hunk expands a short signature, which
looks wrong until you see why: the hook rewrites `path=None` to `path = None`
first, and the longer line then no longer fits.

Nothing but whitespace: comment_tools.py check --strict-ext reports 3/3 OK, so
every AST is unchanged. test_diffusers_prewarm.py 28 passed,
test_amd_extras_contract.py 10 passed. Re-running the hook over the whole tree
afterwards touches these three files and nothing else.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-15T14:33:47.691987Z e115e0f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: e115e0f918

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@danielhanchen
danielhanchen merged commit bda17fd into main Sep 15, 2026
38 checks passed
@danielhanchen
danielhanchen deleted the ci/format-main-to-its-own-hook branch September 15, 2026 17:14
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…ain (unslothai#11019)

main is not formatted the way its own pre-commit hook formats. Running
scripts/run_ruff_format.py with the pinned ruff 0.6.9 over every file the hook
selects changes three files on 52fb7b0:

    studio/backend/tests/test_diffusers_prewarm.py   (unslothai#10989)
    studio/backend/utils/torch_warmup.py             (unslothai#10989)
    tests/python/test_amd_extras_contract.py         (unslothai#7536)

Both of those PRs merged in the last hour with `pre-commit.ci - pr` in ERROR.

That is not only a tidiness problem, because it takes pre-commit.ci's autofix
down for every OTHER pull request. The hook runs against the PR merged with
main, so every PR's tree now contains these three files needing reformatting;
the autofix patch is computed over them and then cannot be applied to a head
that does not carry main's copy. Three PRs are red on exactly that, each with a
one-or-two-line formatting delta it cannot self-heal, all reporting:

    a conflict occurred when applying fixes to the pr.
    try pulling the upstream branch

So this is self-sustaining: unformatted code on main disables the autofix, and
PRs then merge red because nothing can push the fix for them.

The formatter, not the code, is the thing to trust here: it is pinned in
.pre-commit-config.yaml, and it is idempotent. Running it again over these files
changes nothing on the second or third pass, so this is a fixed point rather
than one step of a moving target. One hunk expands a short signature, which
looks wrong until you see why: the hook rewrites `path=None` to `path = None`
first, and the longer line then no longer fits.

Nothing but whitespace: comment_tools.py check --strict-ext reports 3/3 OK, so
every AST is unchanged. test_diffusers_prewarm.py 28 passed,
test_amd_extras_contract.py 10 passed. Re-running the hook over the whole tree
afterwards touches these three files and nothing else.
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.

1 participant