Repository navigation
MAINT: Make uv the default pre-commit hook installer - #3318
Merged
Roman Lutz (romanlutz) merged 5 commits intoOct 20, 2026
Merged
Roman Lutz (romanlutz) merged 5 commits into
Roman Lutz (romanlutz) merged 5 commits into
Conversation
pre-commit builds Python hook environments with virtualenv and python -m pip install even when it is started with uv run. Document a pinned, opt-in command that runs it with pre-commit-uv so the hook environments are created with uv venv and uv pip install, how to check that pre-commit-uv is active, and how to prepare the hooks while online and then run pre-commit run --all-files offline. No dependency, lock or CI changes. Also fix a typo in the existing note. Fixes microsoft#3148
Add pre-commit-uv to the dev dependencies so that uv run pre-commit creates the Python hook environments with uv venv and installs the hooks with uv pip install. Pin the uv package to 0.9.17, the version CI installs with setup-uv. pre-commit-uv uses it for the hook environments, and under uv run it is also the uv that the ty-check hook calls. pre-commit-uv 4.4.0 needs uv>=0.12.22, so the lock resolves 4.3.0; 4.4.0 changed only packaging and CI. Dependabot now ignores uv, since it would bump the pin but not the setup-uv versions, and a contract test checks that they match. Change the pre-commit cache key in CI, since pre-commit-uv rebuilds hook environments that virtualenv created. Update the docs to the normal commands. Hook revisions and hook selection are unchanged.
Replace the exact uv pin with a lower bound so updates can move uv in uv.lock, drop the Dependabot ignore for uv, and check the locked uv version against the setup-uv versions in the workflows instead of the manifest pin.
Select the project uv version directly from uv.lock with setup-uv instead of synchronizing hardcoded CI versions by hand. Keep versioned documentation bootstraps independent for older release lockfiles, and test the workflow wiring rather than a specific version. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1ead50e2-263b-4043-9fe8-c110a47a3f79
Roman Lutz (romanlutz)
approved these changes
Oct 20, 2026
Integrate upstream main at 7773bb4 before updating PR microsoft#3318. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1ead50e2-263b-4043-9fe8-c110a47a3f79
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.
Fixes #3148
Adds pre-commit-uv to the dev dependencies, so after
uv syncthe normaluv run pre-commitcommands build the Python hook environments with uv instead of virtualenv and pip..pre-commit-config.yamlis unchanged.uvis a dev dependency with a>=0.9.17lower bound, anduv.lockselects 0.9.17, the version CI installs with setup-uv. Underuv runit is also the uv the ty-check hook calls. Dependabot can update uv through the lockfile, and a contract test checks the locked version against every setup-uv version so the CI version moves with it. The lock adds only these two packages; uv also rewrote markers on 12 existing entries, and exported requirements are unchanged apart from the two additions.The CI pre-commit cache key gets a
uvprefix, since pre-commit-uv rebuilds environments that virtualenv created. The docs now use the normal commands.Tested on Windows. Control: with
DISABLE_PRE_COMMIT_UV_PATCH=1, an empty PRE_COMMIT_HOME and pip blocked,install-hooksfails on nbstripout (No matching distribution found for setuptools>=77). With the change, from cold caches with pip blocked,install-hooksbuilt all six environments with uv, and a guarded offlineuv run pre-commit run --all-filespassed all 18 hooks with no network attempts.