Related issues
Several issues appear to share the same missing primitive: creating/updating Python hook environments via a uv sync-style operation, instead of installing ad-hoc dependencies.
Problem
Current Python hook behaviour forces trade-offs:
Core idea
Add a uv-backed mode that:
- creates a dedicated hook venv (as Python hooks already do),
- populates it via lockfile-driven sync (
uv.lock) using defined dependency groups in frozen mode.
Or put differently: make using prek with uv-based projects feel like using uv.
Option A — new language variant python-uv
Introduce a new language (name bikesheddable) meaning:
“Create and populate the hook environment using uv sync semantics.”
Example:
- repo: local
hooks:
- id: mypy
name: mypy (uv-synced)
language: python-uv
entry: mypy
dependency_groups: [typecheck]
Characteristics:
Option B — extend language: python with lockfile + groups/extras
Instead of a new language, extend language: python with opt-in configuration.
Example:
- repo: local
hooks:
- id: mypy
language: python
entry: mypy
lockfile: uv.lock
dependency_groups: [typecheck]
Semantics:
- Setting
lockfile switches environment population to uv sync-style behaviour.
dependency_groups / extras select what is installed.
- Default behaviour remains unchanged if
lockfile is not specified.
Lockfile handling
Initial scope:
Future extension:
- Support additional lock formats (e.g.
py.lock) without changing the high-level configuration model.
This directly addresses reproducibility concerns from #1311 while keeping the initial scope small.
Why this solves the linked issues
I tend to option A.
Related issues
Several issues appear to share the same missing primitive: creating/updating Python hook environments via a
uv sync-style operation, instead of installing ad-hoc dependencies.pyproject.tomldependency group #1462 — manage hook tool dependencies (ruff/mypy/ty, etc.) viapyproject.tomldependency groups and keep them in a single lockfilelanguage: pythonhooks in the project's active venv #1485 — type checking (ty/mypy) typically requires all project dependencies to be installed (similar to Support installing dependencies from pyproject.toml as additional dependencies #780)uv runwork but feel like a workaround that could be first-classrepo: localand run.Problem
Current Python hook behaviour forces trade-offs:
language: pythonhooks in the project's active venv #1485).pyproject.tomland are locked inuv.lock(Manage Python hook tool dependencies viapyproject.tomldependency group #1462).uv run, but this is not an explicit first-class model (Suggestion: Distinguished repo type for local running under uv #998).Core idea
Add a uv-backed mode that:
uv.lock) using defined dependency groups in frozen mode.Or put differently: make using prek with uv-based projects feel like using
uv.Option A — new language variant
python-uvIntroduce a new language (name bikesheddable) meaning:
Example:
Characteristics:
python-uvimplicitly usesuv.lockif present (frozen mode).typecheck) that installs everything required for type checking (Support runninglanguage: pythonhooks in the project's active venv #1485).pyproject.tomland be locked inuv.lock(Manage Python hook tool dependencies viapyproject.tomldependency group #1462).prek.toml/.pre-commit-config.yaml, hook-providing repos can publish normal Python hooks while consuming repos enforce lockfile usage by overriding the language.Option B — extend
language: pythonwithlockfile+ groups/extrasInstead of a new language, extend
language: pythonwith opt-in configuration.Example:
Semantics:
lockfileswitches environment population to uv sync-style behaviour.dependency_groups/extrasselect what is installed.lockfileis not specified.Lockfile handling
Initial scope:
uv.lock.Future extension:
py.lock) without changing the high-level configuration model.This directly addresses reproducibility concerns from #1311 while keeping the initial scope small.
Why this solves the linked issues
uv.lock.pyproject.tomldependency group #1462 (dependency groups) — hook tool dependencies can be defined inpyproject.tomland locked once.language: pythonhooks in the project's active venv #1485 (type checking) — instead of using the active venv, hooks can create a fast, dedicated uv-synced environment containing all required dependencies.uv runpatterns.I tend to option
A.