fix(lint): the ruff pre-commit hook runs again: --force-exclude given once #1837

Merged
HumanBean merged 1 commit from GrimVisage/Longshot:fix/ruff-hook-args into main 2026-11-20 22:55:12 +00:00
Contributor

Summary

Since #1802, every commit that changes a Python file fails its pre-commit hook, and so does mise run lint: ruff refuses to start with error: the argument '--force-exclude' cannot be used multiple times. The ruff-pre-commit v0.12.0 hook's own entry is already ruff check --force-exclude, and .pre-commit-config.yaml gave args: [--force-exclude] on top. This drops the extra argument; ruff.toml's excludes still apply through the entry's flag.

To see it on main: change any .py file and git commit, or run pre-commit run ruff --files scripts/dev.py.

Read first: .pre-commit-config.yaml, the ruff hook.

Testing

Tested: Fedora 45 (Linux 7.3), pre-commit 4.0.1 from mise. pre-commit run ruff --files scripts/dev.py fails on main with the error above and passes here. mise run lint: pre-commit passes; actionlint then fails on .forgejo/workflows/build-windows.yml (SC2016), which this doesn't touch and which fails on main too. mise run test: 704 passed, 150 failed, 17 skipped. 107 of the failures are --strict refusing to skip checks whose tools this PC doesn't have (the Vulkan and SPIR-V headers, spirv-val); the others don't read .pre-commit-config.yaml, the only file this changes, so they fail the same way on main.

Still to test: None.

Measurements

Nothing to measure: a hook's configuration, no code the game runs.

Risks

None for players. If ruff-pre-commit is moved to a version whose entry no longer passes --force-exclude, ruff.toml's excludes would stop applying to files pre-commit names directly; the comment on the hook says why the flag isn't there. A revert brings the error back.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary Since #1802, every commit that changes a Python file fails its pre-commit hook, and so does `mise run lint`: ruff refuses to start with `error: the argument '--force-exclude' cannot be used multiple times`. The ruff-pre-commit v0.12.0 hook's own entry is already `ruff check --force-exclude`, and `.pre-commit-config.yaml` gave `args: [--force-exclude]` on top. This drops the extra argument; ruff.toml's excludes still apply through the entry's flag. To see it on `main`: change any `.py` file and `git commit`, or run `pre-commit run ruff --files scripts/dev.py`. Read first: `.pre-commit-config.yaml`, the ruff hook. ## Testing **Tested:** Fedora 45 (Linux 7.3), pre-commit 4.0.1 from mise. `pre-commit run ruff --files scripts/dev.py` fails on `main` with the error above and passes here. `mise run lint`: pre-commit passes; actionlint then fails on `.forgejo/workflows/build-windows.yml` (SC2016), which this doesn't touch and which fails on `main` too. `mise run test`: 704 passed, 150 failed, 17 skipped. 107 of the failures are `--strict` refusing to skip checks whose tools this PC doesn't have (the Vulkan and SPIR-V headers, `spirv-val`); the others don't read `.pre-commit-config.yaml`, the only file this changes, so they fail the same way on `main`. **Still to test:** None. ## Measurements Nothing to measure: a hook's configuration, no code the game runs. ## Risks None for players. If ruff-pre-commit is moved to a version whose entry no longer passes `--force-exclude`, ruff.toml's excludes would stop applying to files pre-commit names directly; the comment on the hook says why the flag isn't there. A revert brings the error back. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(lint): the ruff pre-commit hook runs again: --force-exclude given once
Some checks are pending
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 16s
5bc4231848
ruff-pre-commit v0.12.0's hook entry is `ruff check --force-exclude`; the config's
args gave it again, and ruff refused to start ("the argument '--force-exclude'
cannot be used multiple times"), so every commit or `mise run lint` that touches
a Python file failed. ruff.toml's excludes still apply through the entry's flag.

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Closing this for now: withdrawn by the author, no review needed. The ruff hook's duplicate --force-exclude is still on main if someone else wants to fix it.

Closing this for now: withdrawn by the author, no review needed. The ruff hook's duplicate --force-exclude is still on main if someone else wants to fix it.
Author
Contributor

Reopened: I closed this by mistake. It is still ready for review.

Reopened: I closed this by mistake. It is still ready for review.
HumanBean left a comment

Recommendation: Approve. It removes a duplicate --force-exclude that makes ruff refuse to start, so the pre-commit hook and mise run lint work again for every Python change, and ruff.toml's excludes still apply through the hook's own entry. Recommend approval; not approved on the forge.

For contributors: committing a .py change no longer fails in the ruff hook with the argument '--force-exclude' cannot be used multiple times. It makes the config better and nothing gets worse. Players get nothing new and lose nothing.

Does it help: not a perf change. The fix holds up on reading: ruff-pre-commit v0.12.0's ruff hook already has entry: ruff check --force-exclude, and ruff's CLI (clap 4) refuses a boolean flag given twice. The author's run agrees: pre-commit run ruff --files scripts/dev.py fails on main and passes on this head.
Other systems: the CircleCI lint job (.circleci/shared.yml, pre-commit run --from-ref $BASE --to-ref HEAD) runs the same hook from the same file, so it gets the same fix. Forgejo's ci.yml doesn't run pre-commit. No game, build or packaging code reads the ruff hook (scripts/devtools/packs.py lists .pre-commit-config.yaml as not built). The other hooks are untouched.
Switches: none.

Reviewed: 5bc4231848 against 3df5c13ed2 (main@origin): .pre-commit-config.yaml in full, ruff.toml, mise.toml (the ruff pin and the lint task), .circleci/shared.yml's lint job, .forgejo/workflows/ci.yml, and 068fb8ebe2 (#1802), which added args: [--force-exclude]. Nothing run (a code review).
Fixed in this review: nothing.
Checked and fine:

  • The pins match: ruff-pre-commit rev: v0.12.0 and mise's pypi:ruff = 0.12.0.
  • The ruff hook id is valid at that rev.
  • The exclusions still apply. pre-commit passes file names to ruff directly, and --force-exclude (now from the entry, given once) makes ruff apply ruff.toml's extend-exclude (third_party, gpu/third_party, gpu/vk/sirit, website/node_modules, _deps, docs/old) to those files too. Before #1802 there were no pre-commit-level exclude: patterns on the ruff hook, and none are lost now.
  • The vendored-folder exclude: patterns on end-of-file-fixer and trailing-whitespace are unchanged.
  • The trailing # ... comment after - id: ruff is valid YAML.
  • The diff is on one topic and matches the description. The checklist boxes are honest: the failing tests are named as also failing on main and don't read this file.

Suggestions (the author may take or leave)

  • .pre-commit-config.yaml:38: the rest of the file puts comments on their own line above the entry. A line above - id: ruff reads better than a trailing comment, and it is where someone bumping rev: will look.

Testing: by the author on Fedora 45 (pre-commit 4.0.1): the hook fails on main and passes here; mise run lint gets past pre-commit, then actionlint fails on build-windows.yml (SC2016), which fails on main too. CI's pre-commit only checks changed files, and this PR changes no .py file, so CI won't run the ruff hook on this PR. The author's run is the evidence. Nothing else is needed: no game or hardware path.
Overlaps and merge order: #68 also edits .pre-commit-config.yaml, but only the trailing-whitespace exclude: (lines 9-12). There's no overlap with the ruff hook and no textual conflict, so either can merge first. No other open PR touches the ruff hook.

**Recommendation: Approve.** It removes a duplicate `--force-exclude` that makes ruff refuse to start, so the pre-commit hook and `mise run lint` work again for every Python change, and ruff.toml's excludes still apply through the hook's own entry. Recommend approval; not approved on the forge. For contributors: committing a `.py` change no longer fails in the ruff hook with `the argument '--force-exclude' cannot be used multiple times`. It makes the config better and nothing gets worse. Players get nothing new and lose nothing. **Does it help:** not a perf change. The fix holds up on reading: ruff-pre-commit v0.12.0's `ruff` hook already has `entry: ruff check --force-exclude`, and ruff's CLI (clap 4) refuses a boolean flag given twice. The author's run agrees: `pre-commit run ruff --files scripts/dev.py` fails on `main` and passes on this head. **Other systems:** the CircleCI `lint` job (`.circleci/shared.yml`, `pre-commit run --from-ref $BASE --to-ref HEAD`) runs the same hook from the same file, so it gets the same fix. Forgejo's `ci.yml` doesn't run pre-commit. No game, build or packaging code reads the ruff hook (`scripts/devtools/packs.py` lists `.pre-commit-config.yaml` as not built). The other hooks are untouched. **Switches:** none. **Reviewed:** 5bc423184875 against 3df5c13ed2ec (main@origin): `.pre-commit-config.yaml` in full, `ruff.toml`, `mise.toml` (the ruff pin and the `lint` task), `.circleci/shared.yml`'s lint job, `.forgejo/workflows/ci.yml`, and 068fb8ebe232 ([#1802](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1802)), which added `args: [--force-exclude]`. Nothing run (a code review). **Fixed in this review:** nothing. **Checked and fine:** - The pins match: ruff-pre-commit `rev: v0.12.0` and mise's `pypi:ruff = 0.12.0`. - The `ruff` hook id is valid at that rev. - The exclusions still apply. pre-commit passes file names to ruff directly, and `--force-exclude` (now from the entry, given once) makes ruff apply ruff.toml's `extend-exclude` (`third_party`, `gpu/third_party`, `gpu/vk/sirit`, `website/node_modules`, `_deps`, `docs/old`) to those files too. Before #1802 there were no pre-commit-level `exclude:` patterns on the ruff hook, and none are lost now. - The vendored-folder `exclude:` patterns on end-of-file-fixer and trailing-whitespace are unchanged. - The trailing `# ...` comment after `- id: ruff` is valid YAML. - The diff is on one topic and matches the description. The checklist boxes are honest: the failing tests are named as also failing on `main` and don't read this file. **Suggestions** (the author may take or leave) - `.pre-commit-config.yaml:38`: the rest of the file puts comments on their own line above the entry. A line above `- id: ruff` reads better than a trailing comment, and it is where someone bumping `rev:` will look. **Testing:** by the author on Fedora 45 (pre-commit 4.0.1): the hook fails on `main` and passes here; `mise run lint` gets past pre-commit, then actionlint fails on `build-windows.yml` (SC2016), which fails on `main` too. CI's pre-commit only checks changed files, and this PR changes no `.py` file, so CI won't run the ruff hook on this PR. The author's run is the evidence. Nothing else is needed: no game or hardware path. **Overlaps and merge order:** [#68](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/68) also edits `.pre-commit-config.yaml`, but only the trailing-whitespace `exclude:` (lines 9-12). There's no overlap with the ruff hook and no textual conflict, so either can merge first. No other open PR touches the ruff hook.
@ -37,3 +37,2 @@
hooks:
- id: ruff
args: [--force-exclude]
- id: ruff # (the hook's entry passes --force-exclude itself; given again, ruff refuses to run)
Owner

Nit: the rest of this file puts comments on their own line above the entry; a line above - id: ruff would match, and is where someone bumping rev: looks.

Nit: the rest of this file puts comments on their own line above the entry; a line above `- id: ruff` would match, and is where someone bumping `rev:` looks.
HumanBean deleted branch fix/ruff-hook-args 2026-11-20 22:55:13 +00:00
Some checks are pending
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 16s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1837
No description provided.