Skip to content

MAINT: Make uv the default pre-commit hook installer - #3318

Merged
Roman Lutz (romanlutz) merged 5 commits into
microsoft:mainfrom
Thanatos9404:feat/3148-uv-precommit-envs
Oct 20, 2026
Merged

Roman Lutz (romanlutz) merged 5 commits into
microsoft:mainfrom
Thanatos9404:feat/3148-uv-precommit-envs

Conversation

@Thanatos9404

@Thanatos9404 Yashvardhan Thanvi (Thanatos9404) commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3148

Adds pre-commit-uv to the dev dependencies, so after uv sync the normal uv run pre-commit commands build the Python hook environments with uv instead of virtualenv and pip. .pre-commit-config.yaml is unchanged.

uv is a dev dependency with a >=0.9.17 lower bound, and uv.lock selects 0.9.17, the version CI installs with setup-uv. Under uv run it 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 uv prefix, 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-hooks fails on nbstripout (No matching distribution found for setuptools>=77). With the change, from cold caches with pip blocked, install-hooks built all six environments with uv, and a guarded offline uv run pre-commit run --all-files passed all 18 hooks with no network attempts.

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
Comment thread doc/contributing/8_pre_commit.md Outdated
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.
@Thanatos9404 Yashvardhan Thanvi (Thanatos9404) changed the title DOC: Document uv-only preparation of pre-commit hook environments MAINT: Make uv the default pre-commit hook installer Oct 19, 2026
Comment thread pyproject.toml Outdated
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
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
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 20, 2026
Merged via the queue into microsoft:main with commit 552bef2 Oct 20, 2026
69 checks passed
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.

FEAT: Support uv-only preparation of pre-commit hook environments

2 participants