chore: use uv run ruff in pre-commit hooks#436
Open
andreatgretel wants to merge 4 commits intomainfrom
Open
Conversation
The pre-commit hook was pinned at v0.12.3 while pyproject.toml requires >=0.14.10 (resolving to 0.15.5). This version mismatch caused the pre-commit formatter to produce output that CI's ruff rejected.
Contributor
Greptile SummaryThis PR replaces the externally-pinned
|
| Filename | Overview |
|---|---|
| .pre-commit-config.yaml | Replaces the pinned astral-sh/ruff-pre-commit remote hook with two local language: system hooks that delegate to uv run ruff check --fix and uv run ruff format, ensuring the ruff version always matches pyproject.toml's ruff>=0.14.10 constraint. No functional issues found. |
Sequence Diagram
sequenceDiagram
participant Dev as Developer
participant PC as pre-commit
participant UV as uv run
participant Ruff as ruff (from pyproject.toml)
Dev->>PC: git commit
PC->>PC: Run pre-commit-hooks (whitespace, yaml, etc.)
PC->>UV: uv run ruff check --fix [staged files]
UV->>Ruff: Resolve ruff>=0.14.10 from uv environment
Ruff-->>UV: Lint result (fixes applied or errors)
UV-->>PC: Exit code
alt Files modified by --fix
PC-->>Dev: Hook failed — re-stage and recommit
else Unfixable lint errors
PC-->>Dev: Hook failed — fix errors manually
else No issues
PC->>UV: uv run ruff format [staged files]
UV->>Ruff: Resolve ruff>=0.14.10 from uv environment
Ruff-->>UV: Format result
UV-->>PC: Exit code
alt Files reformatted
PC-->>Dev: Hook failed — re-stage and recommit
else Already formatted
PC-->>Dev: All hooks passed — commit created
end
end
Last reviewed commit: "Merge branch 'main' ..."
Replaces the external ruff-pre-commit repo with local hooks that run .venv/bin/ruff directly. This guarantees the pre-commit ruff version always matches CI (both use the version from pyproject.toml), eliminating version drift that caused formatting mismatches.
32dd8a7 to
667d0fe
Compare
nabinchha
previously approved these changes
Mar 18, 2026
Replaces .venv/bin/ruff with uv run ruff so the hooks work on any platform without requiring a pre-existing venv. Also fixes the misleading "legacy alias" hook name.
nabinchha
approved these changes
Mar 18, 2026
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
Replaces the external
astral-sh/ruff-pre-commitrepo with locallanguage: systemhooks that useuv run ruff. This ensures the pre-commit version always matchespyproject.tomland works cross-platform.Changes
Changed
.pre-commit-config.yaml- Replacedastral-sh/ruff-pre-commit(pinned atv0.12.3) with two local hooks usinguv run ruff check --fixanduv run ruff formatFixed
v0.12.3) and CI (>=0.14.10) that caused divergent ternary-expression formatting.venv/bin/paths)Description updated with AI