Skip to main content

Run pre-commit with uv

Project description

pre-commit-uv

PyPI PyPI - Implementation PyPI - Python Version Downloads PyPI - License check

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pre_commit_uv-4.1.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

pre_commit_uv-4.1.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file pre_commit_uv-4.1.1.tar.gz.

File metadata

  • Download URL: pre_commit_uv-4.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for pre_commit_uv-4.1.1.tar.gz
Algorithm Hash digest
SHA256 f9453a7bac7fc464ba19ca32da428b19c772a30d562d1eafbd3f5a58ccf87d2f
MD5 6acc4a27088d56598f6254bdfedec0c7
BLAKE2b-256 8d44bea6d3d3898305e1dd2520566fe75abc68be0dabd920abff90ab8c51db97

See more details on using hashes here.

File details

Details for the file pre_commit_uv-4.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pre_commit_uv-4.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cfb05fd59095cd10f97aeb253e2c4200c75127edcc3ec0068d2b34137bdcc217
MD5 651b8db16d64f6c41b8058f67d41d270
BLAKE2b-256 37e29ffb6b5acb2087d99a6f0ee90b4c5bea9976c3db271a6d70c63c5d04fed3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page