Run pre-commit with uv
Project description
pre-commit-uv
Use uv to create virtual environments and install packages for pre-commit.
Installation
With pipx:
pipx install pre-commit
pipx inject pre-commit pre-commit-uv
With uv:
uv tool install pre-commit --with pre-commit-uv --force-reinstall
Why?
Compared to upstream pre-commit will speed up the initial seed operation. In general, upstream recommends caching the
pre-commit cache, however, that is not always possible and is still helpful to have a more performant initial cache
creation., Here's an example of what you could expect demonstrated on this project's own pre-commit setup (with a hot
uv cache):
❯ hyperfine  'pre-commit install-hooks' 'pre-commit-uv install-hooks'
Benchmark 1: pre-commit install-hooks
  Time (mean ± σ):     54.132 s ±  8.827 s    [User: 15.424 s, System: 9.359 s]
  Range (min … max):   45.972 s … 66.506 s    10 runs
Benchmark 2: pre-commit-uv install-hooks
  Time (mean ± σ):     41.695 s ±  7.395 s    [User: 7.614 s, System: 6.133 s]
  Range (min … max):   32.198 s … 58.467 s    10 runs
Summary
  pre-commit-uv install-hooks ran 1.30 ± 0.31 times faster than pre-commit install-hooks
Configuration
Once installed will use uv out of box, however the DISABLE_PRE_COMMIT_UV_PATCH environment variable if is set it
will work as an escape hatch to disable the new behavior.
To avoid interpreter startup overhead of the patching, we only perform this when we detect you calling pre-commit.
Should this logic fail you can force the patching by setting the FORCE_PRE_COMMIT_UV_PATCH variable. Should you
experience this please raise an issue with the content of the sys.argv. Note that DISABLE_PRE_COMMIT_UV_PATCH will
overwrite this flag should both be set.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
    Details for the file pre_commit_uv-4.2.0.tar.gz.
  
File metadata
- Download URL: pre_commit_uv-4.2.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | c32bb1d90235507726eee2aeef2be5fdab431a6f1906e3f1addb0a4e99b369d1 | |
| MD5 | 96267a6ca2205fef625f45b58b023006 | |
| BLAKE2b-256 | f64284372bc99a841bfdd8b182a50186471a7f5e873d8e8bcec0d0cb6dabcbb0 | 
Provenance
    The following attestation bundles were made for pre_commit_uv-4.2.0.tar.gz:
  
      Publisher: 
      
      release.yaml on tox-dev/pre-commit-uv
    
  
- 
              Statement:
              - 
                  Statement type: https://in-toto.io/Statement/v1
- 
                  Predicate type: https://docs.pypi.org/attestations/publish/v1
- 
                  Subject name: pre_commit_uv-4.2.0.tar.gz
- 
                  Subject digest: c32bb1d90235507726eee2aeef2be5fdab431a6f1906e3f1addb0a4e99b369d1
- Sigstore transparency entry: 597838276
- Sigstore integration time:
 - 
                    Permalink: 
                    tox-dev/pre-commit-uv@05e9b0a4d33a9c52d8dd7d04b3ea4ef3648bf038
- 
                  Branch / Tag: 
                  refs/tags/4.2.0
- Owner: https://github.com/tox-dev
- 
                Access: public
 - 
              Token Issuer: https://token.actions.githubusercontent.com
- 
                Runner Environment: github-hosted
- 
                Publication workflow:
                
                  release.yaml@05e9b0a4d33a9c52d8dd7d04b3ea4ef3648bf038
- 
                Trigger Event: push
 
- 
                  Statement type: 
File details
    Details for the file pre_commit_uv-4.2.0-py3-none-any.whl.
  
File metadata
- Download URL: pre_commit_uv-4.2.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | cc1b56641e6c62d90a4d8b4f0af6f2610f1c397ce81af024e768c0f33715cb81 | |
| MD5 | 690c04b152bb6ce0c547ae01ec1cb2a5 | |
| BLAKE2b-256 | 879fec8491f6b3022489a4d36ce372214c10a34f90b425aa61ff2e0a8dc5b9d5 | 
Provenance
    The following attestation bundles were made for pre_commit_uv-4.2.0-py3-none-any.whl:
  
      Publisher: 
      
      release.yaml on tox-dev/pre-commit-uv
    
  
- 
              Statement:
              - 
                  Statement type: https://in-toto.io/Statement/v1
- 
                  Predicate type: https://docs.pypi.org/attestations/publish/v1
- 
                  Subject name: pre_commit_uv-4.2.0-py3-none-any.whl
- 
                  Subject digest: cc1b56641e6c62d90a4d8b4f0af6f2610f1c397ce81af024e768c0f33715cb81
- Sigstore transparency entry: 597838295
- Sigstore integration time:
 - 
                    Permalink: 
                    tox-dev/pre-commit-uv@05e9b0a4d33a9c52d8dd7d04b3ea4ef3648bf038
- 
                  Branch / Tag: 
                  refs/tags/4.2.0
- Owner: https://github.com/tox-dev
- 
                Access: public
 - 
              Token Issuer: https://token.actions.githubusercontent.com
- 
                Runner Environment: github-hosted
- 
                Publication workflow:
                
                  release.yaml@05e9b0a4d33a9c52d8dd7d04b3ea4ef3648bf038
- 
                Trigger Event: push
 
- 
                  Statement type: