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.2.2.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pre_commit_uv-4.2.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pre_commit_uv-4.2.2.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pre_commit_uv-4.2.2.tar.gz
Algorithm Hash digest
SHA256 8c94e1fb660ab3071fd32afb3bb4b43e1930612a8fec7cf03e9cfb7bffd5c5dc
MD5 3ff4f5a753a69181fa26f68712cb4ccb
BLAKE2b-256 c7943770b38b1643c3fc892ea7899f3671eb0f4d4fcbd33c1abe15641dfb1354

See more details on using hashes here.

Provenance

The following attestation bundles were made for pre_commit_uv-4.2.2.tar.gz:

Publisher: release.yaml on tox-dev/pre-commit-uv

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: pre_commit_uv-4.2.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pre_commit_uv-4.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5f86c77d8b1631a09a6b7c261247b235d46f0d757429c5aff3b52a63bc20dc62
MD5 e671d5c1163490e7142f6eec7d0ddd5e
BLAKE2b-256 5690bccb5c4b82cebd20b0b1464f6f03c07388327ddf143cf47deea72153f918

See more details on using hashes here.

Provenance

The following attestation bundles were made for pre_commit_uv-4.2.2-py3-none-any.whl:

Publisher: release.yaml on tox-dev/pre-commit-uv

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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