Skip to content

use uv run --no-sync in pre-commit commands#6472

Merged
masenf merged 1 commit intomainfrom
masenf/uv-run-pre-commit
May 8, 2026
Merged

use uv run --no-sync in pre-commit commands#6472
masenf merged 1 commit intomainfrom
masenf/uv-run-pre-commit

Conversation

@masenf
Copy link
Copy Markdown
Collaborator

@masenf masenf commented May 7, 2026

allow pre-commit to work whether you have activated the virtualenv or not

allow pre-commit to work whether you have activated the virtualenv or not
@masenf masenf requested a review from a team as a code owner May 7, 2026 23:24
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 7, 2026

Greptile Summary

This PR updates .pre-commit-config.yaml to invoke every hook via uv run --no-sync instead of calling tools directly, so pre-commit works correctly whether or not the project virtualenv is activated.

  • All five hook entries (ruff format, ruff check, codespell, python scripts/make_pyi.py, pyright) are prefixed with uv run --no-sync, delegating Python/tool resolution to uv without triggering a dependency sync on each run.
  • The make_pyi hook also changes its invocation from python3 to python; under uv run this is handled by uv's Python resolver and is safe.

Confidence Score: 5/5

This PR is safe to merge β€” it makes a narrow, mechanical change to pre-commit hook invocations with no logic or runtime code affected.

The change only touches the pre-commit config, adding uv run --no-sync in front of each tool invocation. The --no-sync flag correctly skips dependency syncing (keeping hook startup fast), and uv's Python resolver handles the python vs python3 rename in the make_pyi hook cleanly. There are no behavioural regressions expected.

No files require special attention.

Important Files Changed

Filename Overview
.pre-commit-config.yaml All five hook entry-points prefixed with uv run --no-sync so pre-commit works with or without an activated virtualenv; python3 β†’ python in the make_pyi hook.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[git commit triggered] --> B[pre-commit runs hooks]
    B --> C{virtualenv activated?}
    C -- Before PR: Yes --> D[Direct tool invocation\ne.g. ruff format]
    C -- Before PR: No --> E[Tool not found on PATH\n❌ Hook fails]
    C -- After PR: Either --> F[uv run --no-sync tool]
    F --> G[uv resolves tool from\nproject environment]
    G --> H[Hook executes successfully βœ…]
Loading

Reviews (1): Last reviewed commit: "use `uv run --no-sync` in pre-commit com..." | Re-trigger Greptile

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 7, 2026

Merging this PR will not alter performance

βœ… 24 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing masenf/uv-run-pre-commit (4aca13b) with main (2df5344)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@masenf masenf merged commit 1eed933 into main May 8, 2026
68 of 69 checks passed
@masenf masenf deleted the masenf/uv-run-pre-commit branch May 8, 2026 00:30
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.

2 participants