# Installation To ensure black, ruff, ty, pip-audit, and the tests are run on every commit, you can set up pre-commit hooks. ``` poetry add --group dev pre-commit poetry install git commit -a -m "Added pre-commit to dev." ``` With `uv`: ``` uv add --dev pre-commit git commit -a -m "Added pre-commit to dev." ``` # Configuration Now create your configuration in `.pre-commit-config.yaml`, for example, via ``` poetry run pre-commit sample-config > .pre-commit-config.yaml ``` Or with `uv`: ``` uv run pre-commit sample-config > .pre-commit-config.yaml ``` A more targeted, but outdated setup might be (adjust `default_language_version` if relevant): ```yaml cat << PRECOMMIT > .pre-commit-config.yaml repos: - repo: https://github.com/psf/black rev: 25.1.0 hooks: - id: black language_version: python3.13 - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.9.1 hooks: - id: ruff args: [--fix] - repo: local hooks: - id: ty name: ty entry: uv run ty check language: system types: [python] pass_filenames: false always_run: true - id: pytest name: pytest entry: uv run pytest language: system pass_filenames: false always_run: true args: [tests] - repo: https://github.com/pypa/pip-audit rev: v2.10.0 hooks: - id: pip-audit stages: [manual] PRECOMMIT ``` # Setup After you set up the configuration YAML file, you need to install the hooks via: ``` poetry run pre-commit install --install-hooks --overwrite ``` ``` uv run pre-commit install --install-hooks --overwrite ``` FInally, add the pre-commit configuration to your index: ``` git add .pre-commit-config.yaml git commit -m "Added pre-commit config." ```