Skip to content

Manage Python hook tool dependencies via pyproject.toml dependency group #1462

@pygarap

Description

@pygarap

"One uv.lock to rule them all"!

Summary

Add support for managing the Python tool dependencies used by hooks in .pre-commit-config.yaml via a dedicated dependency group in pyproject.toml, and ensure those dependencies are synced into the root uv.lock.

Motivation

In many repos, hooks reference Python tools (for example: ruff, rumdl, mypy, pytest, etc.). Today, those tool versions typically live outside the project dependency management flow, which can lead to:

  • Duplicate version pinning across files.
  • Drift between what CI installs and what developers have locally.
  • A less reproducible setup when using uv with a lock file.

Centralizing these tool versions in pyproject.toml would make hook tooling easier to maintain and more consistent.

Proposed behavior

1. Declare hook tool dependencies in pyproject.toml

Allow users to define a dependency group named prek under [dependency-groups] (PEP 735 style), for example:

[dependency-groups]
prek = [
  "ruff>=0.11.13",
  "rumdl>=0.0.210",
]

Which can be added using uv add --group prek ruff.

2. Sync those dependencies into the root uv.lock

When the repo uses uv and has a root uv.lock, ensure the dependency-groups.prek dependencies are included and locked there, so the hook tooling environment is reproducible.

Expected outcome

  • A single source of truth for Python hook tooling versions.
  • Less duplication between .pre-commit-config.yaml and Python dependency management.
  • A reproducible, locked set of hook tool dependencies via uv.lock.

Notes / scope

  • This request is specifically about Python hook tooling dependencies (not non-Python tools).

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideaJust an idea

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions