Skip to content

Support inline script metadata (PEP 723) in python hooks #509

@potiuk

Description

@potiuk

One thing we discussed in Airlfow in one of the PRs, it would be great if prek supported inline script metadata https://packaging.python.org/en/latest/specifications/inline-script-metadata/ in python hooks.,

That would allow to keep the dependency + script in the same place (not decoupled between .pre-commit-config.yaml and the script implicit dependencies) and we often now copy dependencies in both places to allow also to run the prek hook as regular script with uv run for example.

It probably means that prek would not have to manage the venv for such inline-project matadata hooks, but it could entirely run on uv run running the scripts. The venv used by uv are "throw-away" but also this reflects uv philosophy where the venvs are created and destroyed extremely fast because of aggressive caching and hard-linking by default.

Discussed initially in apache/airflow#54656 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions