Skip to content

Restore the executable bit on the formatter hook - #10519

Merged
danielhanchen merged 4 commits into
mainfrom
fix/formatter-exec-bit
Sep 8, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
fix/formatter-exec-bit

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Summary

pre-commit.ci is red on main and on every open PR with:

Executable `scripts/run_ruff_format.py` is not executable

Two things combine to produce it, and this PR fixes both.

  1. scripts/enforce_kwargs_spacing.py rewrites every file it touches through a mkstemp temp file and os.replace. mkstemp creates the temp file 0600, so the rewrite drops the original's mode, executable bit included.
  2. scripts/run_ruff_format.py is the hook's own entry point and is itself processed by the hook. Make the formatter refuse a ruff it is not pinned to, and re-format the four files that drifted #10512 gave it kwarg spacing, so from then on every run rewrote it, stripped its executable bit, and pre-commit.ci committed the flip as an autofix. The next run then could not execute it.

Change

  • The writer carries the original mode onto the temp file before the replace.
  • scripts/run_ruff_format.py goes back to 100755.
  • A test rewrites a 0755 script and a 0644 file through the pass and checks both modes survive. It fails with the chmod removed.

Verification

  • Reproduced locally with pre-commit and the hook's pinned ruff 0.6.9: before the change a run over the tree leaves run_ruff_format.py at 0600 and git reports a mode change; after it the whole-tree run passes and the tree is unchanged.
  • pre-commit.ci's own autofix on this branch (9a27ae6) is the flip described above, made while only the first half of the fix was in place.

#10512 rewrote scripts/run_ruff_format.py and the file came back 100644, so
pre-commit.ci fails every run, on main and on every open PR, with
"Executable scripts/run_ruff_format.py is not executable" before the hook
does anything. Mode only, no content change.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 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 🔄 Running since 2026-09-08T14:38:36.492265Z 0deba57 New commits
ℹ️ 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.

@pre-commit-ci
pre-commit-ci Bot requested a review from Imagineer99 as a code owner September 8, 2026 14:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a27ae62d2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +111 to +113
assert (
len(specs) == 1
), f"{extra} must resolve exactly one xformers wheel on Windows, got {specs}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore executable mode on the formatter hook

This commit only reformats tests; its tree still records scripts/run_ruff_format.py as mode 100644, identical to the parent. Because .pre-commit-config.yaml invokes that path directly as the ruff-format-with-kwargs entry, Linux/pre-commit runs still fail with Permission denied before formatting, so the CI failure described by this commit remains unresolved. Include the intended 100644 => 100755 mode change.

Useful? React with 👍 / 👎.

… formatter hook's executable bit

The spacing pass rewrites through a mkstemp temp file and os.replace, and
mkstemp creates that file 0600, so every file the pass touches loses its
mode. scripts/run_ruff_format.py is the pre-commit hook's own entry point and
is processed by the hook it runs; #10512 gave it kwarg spacing, so from then
on every run stripped its executable bit, pre-commit.ci committed the flip
(7c48499 here, and main's own push check is red the same way), and the next
run failed before doing anything with "not executable".

The writer now carries the original mode onto the temp file before the
replace, pinned by a test that rewrites a 0755 script and a 0644 file, and
the hook's entry script goes back to 100755.

(cherry picked from commit db7df60daa97fb6191776a6d489c229c3877888f)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0deba57538

ℹ️ 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".


def test_an_executable_script_keeps_its_bit_through_the_rewrite(tmp_path):
target = _rewrite(tmp_path, 0o755)
assert stat.S_IMODE(target.stat().st_mode) == 0o755

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip POSIX mode assertions on Windows

When this new test module is run on Windows, both tests fail even if the rewrite is correct: Windows does not represent POSIX executable/group mode bits, and os.chmod cannot round-trip 0o755 or 0o644 through st_mode. Gate these mode-preservation assertions to POSIX platforms, or assert only the read-only flag that Windows supports.

Useful? React with 👍 / 👎.

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