mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Update pre-commit documentation (#10756)
## Summary Added missing `repos:` line to make the example config complete --------- Co-authored-by: Rajesh Veeranki <rveeranki@d4q74qfn2y.agoda.local> Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
parent
fd16988a4b
commit
cee8770cb0
1 changed files with 42 additions and 37 deletions
|
@ -14,61 +14,66 @@ To make sure your `uv.lock` file is up to date even if your `pyproject.toml` fil
|
|||
pre-commit, add the following to the `.pre-commit-config.yaml`:
|
||||
|
||||
```yaml title=".pre-commit-config.yaml"
|
||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||
# uv version.
|
||||
rev: 0.5.22
|
||||
hooks:
|
||||
- id: uv-lock
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||
# uv version.
|
||||
rev: 0.5.22
|
||||
hooks:
|
||||
- id: uv-lock
|
||||
```
|
||||
|
||||
To keep your `requirements.txt` file updated using pre-commit:
|
||||
|
||||
```yaml title=".pre-commit-config.yaml"
|
||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||
# uv version.
|
||||
rev: 0.5.22
|
||||
hooks:
|
||||
- id: uv-export
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||
# uv version.
|
||||
rev: 0.5.22
|
||||
hooks:
|
||||
- id: uv-export
|
||||
```
|
||||
|
||||
To compile requirements via pre-commit, add the following to the `.pre-commit-config.yaml`:
|
||||
|
||||
```yaml title=".pre-commit-config.yaml"
|
||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||
# uv version.
|
||||
rev: 0.5.22
|
||||
hooks:
|
||||
# Compile requirements
|
||||
- id: pip-compile
|
||||
args: [requirements.in, -o, requirements.txt]
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||
# uv version.
|
||||
rev: 0.5.22
|
||||
hooks:
|
||||
# Compile requirements
|
||||
- id: pip-compile
|
||||
args: [requirements.in, -o, requirements.txt]
|
||||
```
|
||||
|
||||
To compile alternative files, modify `args` and `files`:
|
||||
|
||||
```yaml title=".pre-commit-config.yaml"
|
||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||
# uv version.
|
||||
rev: 0.5.22
|
||||
hooks:
|
||||
# Compile requirements
|
||||
- id: pip-compile
|
||||
args: [requirements-dev.in, -o, requirements-dev.txt]
|
||||
files: ^requirements-dev\.(in|txt)$
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||
# uv version.
|
||||
rev: 0.5.22
|
||||
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 title=".pre-commit-config.yaml"
|
||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||
# uv version.
|
||||
rev: 0.5.22
|
||||
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)$
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||
# uv version.
|
||||
rev: 0.5.22
|
||||
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)$
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue