Run pre-commit with uv
Project Links
Meta
Author: Bernat Gabor
Requires Python: >=3.11
Classifiers
Intended Audience
- Developers
Operating System
- OS Independent
Programming Language
- Python
- Python :: 3 :: Only
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
- Python :: 3.14
- Python :: 3.15
Topic
- Software Development :: Version Control :: Git
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?
pre-commit-uv uses uv to create and seed hook environments. Caching the pre-commit directory avoids this work on later
runs, but the first install still needs it. This benchmark used this project's hooks with a warm 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, pre-commit-uv uses uv by default. Set DISABLE_PRE_COMMIT_UV_PATCH to use pre-commit's normal
installation path instead.
The patch loads when the process appears to be running pre-commit. If detection misses a call, set
FORCE_PRE_COMMIT_UV_PATCH and report the value of sys.argv in an issue. DISABLE_PRE_COMMIT_UV_PATCH takes
precedence when both variables are set.
4.4.3
Nov 18, 2026
4.4.2
Nov 04, 2026
4.4.1
Oct 27, 2026
4.4.0
Oct 11, 2026
4.3.0
Jul 21, 2026
4.2.2
Jun 19, 2026
4.2.1
Feb 18, 2026
4.2.0
Oct 09, 2025
4.1.5
Aug 27, 2025
4.1.4
Oct 29, 2024
4.1.3
Sep 23, 2024
4.1.2
Sep 18, 2024
4.1.1
Sep 08, 2024
4.1.0
Aug 12, 2024
4.0.3
Aug 08, 2024
4.0.2
Aug 07, 2024
4.0.1
Aug 07, 2024
4.0.0
Aug 05, 2024
3.8.0
Jul 31, 2024
3.7.0
Apr 24, 2024
3.6.92
Mar 01, 2024
3.6.2.1
Mar 01, 2024