astral-sh / astral-sh/uv-pre-commit

How to read `--python-version` from file with `pip-compile` hook

Open
#34 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
348
Forks
27
PR merge metrics
No merged PRs in 30d

Description

`uv pip compile` doesn't read `pyproject.toml` or `.python-version` to default the `--python-version` flag (https://github.com/astral-sh/uv/issues/9581). Running `uv pip compile --python-version=$(cat .python-version)` is an acceptable workaround, but this doesn't work using the `pip-compile` pre-commit hook because pre-commit just passes the arguments as literal strings and `uv pip compile` can't do the variable expansion dynamically.

Are there any recommended ways to not have to hardcode `--python-version` here?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the pip-compile pre-commit hook invocation and how pre-commit passes arguments to `uv pip compile`. Compare that behavior with the `.python-version` workaround and determine whether a supported configuration can avoid hardcoding `--python-version`; done means documenting or validating a working approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.