Skip to main content

Run git hooks as shell commands from pyproject.toml

Project description

prehook

CI PyPI License: MIT

Run git hooks configured in pyproject.toml using uv.

Usage

  1. Install (one-time):

    uvx prehook install
    

    Use --force to overwrite existing git hooks.

  2. Update hooks in pyproject.toml:

    [tool.prehook]
    hooks = [
        "uvx ruff check",
        "uvx ruff format",
    ]
    
  3. Commit:

    git commit -m "unfinished commit"
    

To run hooks manually:

uvx prehook run

To uninstall:

uvx prehook uninstall

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.

Both can be overridden from the CLI:

uvx prehook run --parallel --fail-fast

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

prehook-0.5.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

prehook-0.5.0-py3-none-win_amd64.whl (515.4 kB view details)

Uploaded Python 3Windows x86-64

prehook-0.5.0-py3-none-manylinux_2_28_x86_64.whl (596.9 kB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

prehook-0.5.0-py3-none-manylinux_2_28_aarch64.whl (564.7 kB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

prehook-0.5.0-py3-none-macosx_11_0_arm64.whl (554.1 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

prehook-0.5.0-py3-none-macosx_10_12_x86_64.whl (574.4 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file prehook-0.5.0.tar.gz.

File metadata

  • Download URL: prehook-0.5.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for prehook-0.5.0.tar.gz
Algorithm Hash digest
SHA256 4180a7e31a15bf62d90695f603145f8860f73871a1609d247752e489de9fef6d
MD5 cdb2a8630fc5af874bfe6a2aeaf367a4
BLAKE2b-256 dca961434645f5e6e8647431b843c05710e463d88e8a7ee60b0faf33ee096862

See more details on using hashes here.

Provenance

The following attestation bundles were made for prehook-0.5.0.tar.gz:

Publisher: release.yml on scriptogre/prehook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prehook-0.5.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: prehook-0.5.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 515.4 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for prehook-0.5.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 85100e56080cb5c9fd13fc8895111265df85c893d3dc73b29767fcb6d1ff7b15
MD5 b73ea78d23e1c2a8fe536409ff4e6ac5
BLAKE2b-256 9c40e3e16a550b163595f0f2673f6e355a51a6fde75fb5301de3e0c0ba68d650

See more details on using hashes here.

Provenance

The following attestation bundles were made for prehook-0.5.0-py3-none-win_amd64.whl:

Publisher: release.yml on scriptogre/prehook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prehook-0.5.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for prehook-0.5.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 26d8d44315a43288837b286076cdc09cfccad01754a244dcc977242360eb03f0
MD5 780eaae5abdd0146ecdb8f3449709607
BLAKE2b-256 9723694666d3163e80b2917b36f6bdff3a5a8d599f623eb90c71078292173232

See more details on using hashes here.

Provenance

The following attestation bundles were made for prehook-0.5.0-py3-none-manylinux_2_28_x86_64.whl:

Publisher: release.yml on scriptogre/prehook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prehook-0.5.0-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for prehook-0.5.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 963779737290bdd47ce6375ee6a9e783770cdb3efb280ec90c4ee95effebb9b1
MD5 ac663c13eece3beded07a902c02aa82d
BLAKE2b-256 e914ae9b6df42dfffbcb10a3ea859f04ac255341623488a0cabb2fe9a961a34a

See more details on using hashes here.

Provenance

The following attestation bundles were made for prehook-0.5.0-py3-none-manylinux_2_28_aarch64.whl:

Publisher: release.yml on scriptogre/prehook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prehook-0.5.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for prehook-0.5.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4328730b3451635df32437c2feebd7249620f5897971b84f48b8607b2c13ed5a
MD5 3c053d31706d949cf328165d8eddb8e5
BLAKE2b-256 aef74e15577bc43df3a8a6d4a6f13b2c6fa6a1a65441483ccf8ff83347c7c4b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for prehook-0.5.0-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on scriptogre/prehook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prehook-0.5.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for prehook-0.5.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5f22b27aa116b7dee5acb65933fb445cf7ac2e64665134478650f47c64c2e76f
MD5 83043c096cfa5374f193ec1fb0ccaf2b
BLAKE2b-256 ea0c3b58b71915067bc6007aa532a3791dfe7b7f93b295cd026cc40ec43d54a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for prehook-0.5.0-py3-none-macosx_10_12_x86_64.whl:

Publisher: release.yml on scriptogre/prehook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page