Metadata-Version: 2.4
Name: pre-commit-uv
Version: 4.2.1
Summary: Run pre-commit with uv
Project-URL: Bug Tracker, https://github.com/tox-dev/pre-commit-uv/issues
Project-URL: Changelog, https://github.com/tox-dev/pre-commit-uv/releases
Project-URL: Source Code, https://github.com/tox-dev/pre-commit-uv
Project-URL: Documentation, https://github.com/tox-dev/pre-commit-uv/
Author-email: Bernat Gabor <gaborjbernat@gmail.com>
License: Permission is hereby granted, free of charge, to any person obtaining a
        copy of this software and associated documentation files (the
        "Software"), to deal in the Software without restriction, including
        without limitation the rights to use, copy, modify, merge, publish,
        distribute, sublicense, and/or sell copies of the Software, and to
        permit persons to whom the Software is furnished to do so, subject to
        the following conditions:
        
        The above copyright notice and this permission notice shall be included
        in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
        OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
        MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
        IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
        CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
        TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
        SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License-File: LICENSE.txt
Keywords: format,pyproject
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: pre-commit>=4.3
Requires-Dist: uv>=0.9.1
Provides-Extra: testing
Requires-Dist: covdefaults>=2.3; extra == 'testing'
Requires-Dist: pytest-cov>=7; extra == 'testing'
Requires-Dist: pytest-mock>=3.15.1; extra == 'testing'
Requires-Dist: pytest>=8.4.2; extra == 'testing'
Description-Content-Type: text/markdown

# pre-commit-uv

[![PyPI](https://img.shields.io/pypi/v/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
[![PyPI - Implementation](https://img.shields.io/pypi/implementation/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
[![Downloads](https://static.pepy.tech/badge/pre-commit-uv/month)](https://pepy.tech/project/pre-commit-uv)
[![PyPI - License](https://img.shields.io/pypi/l/pre-commit-uv?style=flat-square)](https://opensource.org/licenses/MIT)
[![check](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yaml/badge.svg)](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yaml)

Use `uv` to create virtual environments and install packages for `pre-commit`.

## Installation

With pipx:

```shell
pipx install pre-commit
pipx inject pre-commit pre-commit-uv
```

With uv:

```shell
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):

```shell
❯ 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.
