Run git hooks as shell commands from pyproject.toml
Project description
prehook
Run git hooks configured in pyproject.toml using uv.
Usage
-
Install (one-time):
uvx prehook install
Use
--forceto overwrite existing git hooks.Installed hooks are self-contained
sh(they readpyproject.tomldirectly), so committing never needsprehookitself, and editing the hook list needs no reinstall. -
Update hooks in
pyproject.toml:[tool.prehook] hooks = [ "uvx ruff check", "uvx ruff format", ]
-
Commit:
git commit -m "unfinished commit"
To uninstall:
uvx prehook uninstall
Run the hooks on demand (e.g. in CI) without committing:
uvx prehook run # pre-commit hooks
uvx prehook run --on pre-push # a specific stage
Configuration
Each hook can have a name, target git hook type, and other options:
[tool.prehook]
hooks = [
{ name = "lint", run = "uvx ruff check --fix" },
{ name = "format", run = "uvx ruff format" },
{ name = "typecheck", run = "uvx pyright" },
{ name = "test", run = "pytest", on = ["pre-push"] },
]
| Key | Default | Description |
|---|---|---|
run |
required | Command to execute. |
name |
derived from command | Label for output and SKIP. |
on |
["pre-commit"] |
Which git hook types to run on. |
verbose |
false |
Show output even on success. |
uvx prehook install installs hooks for all supported git hook types, so adding new on values works without reinstalling.
Skipping hooks
SKIP=typecheck git commit -m "wip" # skip by name
SKIP=lint,typecheck git commit -m "wip" # skip multiple
git commit --no-verify -m "wip" # skip all
Parallel and fail fast
[tool.prehook]
parallel = true
fail_fast = true
hooks = [
{ name = "lint+format", run = "uvx ruff check --fix && uvx ruff format" },
{ name = "typecheck", run = "uvx pyright" },
]
| Key | Default | Description |
|---|---|---|
fail_fast |
false |
Stop after first failure. |
parallel |
false |
Run all hooks concurrently. |
Why?
I used pre-commit for a long time, and it's a great tool.
But I prefer less configuration files, and for most projects I just want a quick:
uvx ruff check
uvx ruff format
Which are fast enough to always run on all files (rather than just staged ones).
Alternatives
If this tool doesn't do what you need, these are worth a look:
| Tool | Config | What it does well |
|---|---|---|
| pre-commit | .pre-commit-config.yaml |
Huge ecosystem of ready-made hooks, multi-language virtualenv management. |
| lefthook | lefthook.yml |
Fast, language-agnostic, great parallel execution. |
| prek | prek.toml |
Compatible with pre-commit configs, written in Rust, parallel execution. |
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prehook-0.6.0.tar.gz.
File metadata
- Download URL: prehook-0.6.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f54b5750de71e248fbc4f2466b721f17a670dae4f64c97593fca92a0df159c0
|
|
| MD5 |
89d7bc9c71790b7240b745a98f25cc5e
|
|
| BLAKE2b-256 |
3fb1232a010a4e9d9f0bd39e20e89ae3f6f9f8b966499679605f2347d32c2a69
|
Provenance
The following attestation bundles were made for prehook-0.6.0.tar.gz:
Publisher:
release.yml on scriptogre/prehook
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prehook-0.6.0.tar.gz -
Subject digest:
5f54b5750de71e248fbc4f2466b721f17a670dae4f64c97593fca92a0df159c0 - Sigstore transparency entry: 1872309317
- Sigstore integration time:
-
Permalink:
scriptogre/prehook@1b071f4dd44caa0718db5bb9f8741c244cfece18 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/scriptogre
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1b071f4dd44caa0718db5bb9f8741c244cfece18 -
Trigger Event:
push
-
Statement type:
File details
Details for the file prehook-0.6.0-py3-none-any.whl.
File metadata
- Download URL: prehook-0.6.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cacc99f427f2828b2a589c2ebc78d25da9855eb9ab5d88aa893f4776fd5b5ef1
|
|
| MD5 |
0685de0073027267e3636a25efef6643
|
|
| BLAKE2b-256 |
00ed433c8669ef79450dea8b39764edfe8da8cf7e111a5c85e85d4f326033dd7
|
Provenance
The following attestation bundles were made for prehook-0.6.0-py3-none-any.whl:
Publisher:
release.yml on scriptogre/prehook
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prehook-0.6.0-py3-none-any.whl -
Subject digest:
cacc99f427f2828b2a589c2ebc78d25da9855eb9ab5d88aa893f4776fd5b5ef1 - Sigstore transparency entry: 1872309500
- Sigstore integration time:
-
Permalink:
scriptogre/prehook@1b071f4dd44caa0718db5bb9f8741c244cfece18 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/scriptogre
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1b071f4dd44caa0718db5bb9f8741c244cfece18 -
Trigger Event:
push
-
Statement type: