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

`setuptools-scm` with `uv-lock` `pre-commit` hook workflow broken by `uv==0.5`

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

Description

I have this in my `pre-commit-config.yaml`:

```yaml
default_language_version:
python: python3
repos:
- repo: https://github.com/astral-sh/uv-pre-commit
rev: X
hooks:
- id: uv-lock
```

Notably, I also use `setuptools-scm` for SCM versioning of my package:

```toml
# pyproject.toml

[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=64", "setuptools_scm>=8"]

[project]
dynamic = ["version"]
name = "foo"

[tool.setuptools_scm]
version_file = "foo/version.py"
```

When the `rev` is below `0.5`, the `uv-lock` hook passes within a branch.

After `pre-commit autoupdate` to `uv==0.5.1`, the `uv-lock` hook fails within a branch on a commit-by-commit basis:

```none
[[package]]
name = "foo"
-version = "0.14.3.dev3+ge144e1b"
+version = "0.14.3.dev5+g1ca1866"
```

If you enforce `pre-commit` passing in CI, you seemingly can't win because every commit changes the `uv.lock` file, which leads to failing CI.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the workflow from pre-commit-config.yaml using the pyproject.toml configuration and the uv-lock hook, comparing behavior before and after uv 0.5.1. Inspect the generated uv.lock version entry and run pre-commit in a branch with setuptools-scm enabled; done means uv-lock produces stable output across commits and CI passes consistently.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.