uv/docs/guides/pre-commit.md
Mathieu Kniewallner c9637f00f0
docs: bunch of fixes and improvements (#5136)
## Summary

A bunch of fixes and improvements on different parts of the
documentation. For Docker documentation changes, links to the relevant
documentations have been included in the commit messages.
2024-07-16 20:41:45 -04:00

45 lines
1.2 KiB
Markdown

# Using uv in pre-commit
An official pre-commit hook is provided at [`astral-sh/uv-pre-commit`](https://github.com/astral-sh/uv-pre-commit).
To compile requirements via pre-commit, add the following to the `.pre-commit-config.yaml`:
```yaml
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.2.25
hooks:
# Compile requirements
- id: pip-compile
args: [requirements.in, -o, requirements.txt]
```
To compile alternative files, modify `args` and `files`:
```yaml
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.2.25
hooks:
# Compile requirements
- id: pip-compile
args: [requirements-dev.in, -o, requirements-dev.txt]
files: ^requirements-dev\.(in|txt)$
```
To run the hook over multiple files at the same time:
```yaml
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.2.25
hooks:
# Compile requirements
- id: pip-compile
name: pip-compile requirements.in
args: [requirements.in, -o, requirements.txt]
- id: pip-compile
name: pip-compile requirements-dev.in
args: [requirements-dev.in, -o, requirements-dev.txt]
files: ^requirements-dev\.(in|txt)$
```