Skip to content

fix(pyproject): use uv lock instead of uv add to preserve pyproject.toml#8340

Merged
olblak merged 2 commits intoupdatecli:mainfrom
loispostula:fix/8339-pyproject-uv-lock
Apr 10, 2026
Merged

fix(pyproject): use uv lock instead of uv add to preserve pyproject.toml#8340
olblak merged 2 commits intoupdatecli:mainfrom
loispostula:fix/8339-pyproject-uv-lock

Conversation

@loispostula
Copy link
Copy Markdown
Contributor

Fix #8339

The pyproject autodiscovery generated shell targets using uv add --frozen "PACKAGE>=VERSION" which modifies both pyproject.toml and uv.lock. This replaces it with uv lock --upgrade-package PACKAGE==VERSION which only updates uv.lock, preserving the version constraints in pyproject.toml.

Changes:

  • Target command: uv add --frozenuv lock --upgrade-package PACKAGE==VERSION
  • changedif now only watches uv.lock (no longer tracks pyproject.toml)
  • Removed UvAddGroupFlag (--optional) since uv lock --upgrade-package doesn't need it
  • Removed PyprojectFile from template params

Note: This PR also fixes PEP 440 wildcard version filtering to exclude pre-release versions (dev, alpha, beta, rc) by default, per PEP 440 spec. Previously, * would return e.g. 1.0.dev3 over 0.28.1 or 3.0.0a7 over 2.57.0. Now prefers stable versions, falling back to pre-release only when no stable version exists.

Test

cd pkg/plugins/autodiscovery/pyproject && go test
cd pkg/plugins/utils/version && go test -run TestPep440

Tested manually against a real project with uv.lock — only uv.lock is modified, pyproject.toml stays untouched, and pre-release versions are no longer selected.

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

Tradeoff

None.

Potential improvement

  • Could add a spec option to opt-in to pre-release versions for users who want them.

The pyproject autodiscovery generated shell targets using `uv add --frozen`
which modifies both pyproject.toml and uv.lock. This replaces it with
`uv lock --upgrade-package PACKAGE==VERSION` which only updates uv.lock,
preserving the version constraints in pyproject.toml.

Also removes the UvAddGroupFlag (--optional) since uv lock --upgrade-package
doesn't need it, and simplifies changedif to only watch uv.lock.

Fixes updatecli#8339
Signed-off-by: Loïs Postula <lois@postu.la>
The PEP 440 version filter with wildcard pattern (*) returned pre-release
versions (dev, alpha, beta, rc) as the latest match. Per PEP 440 spec,
pre-releases should be excluded by default.

Now prefers stable versions, falling back to pre-release only when no
stable version exists.

Signed-off-by: Loïs Postula <lois@postu.la>
@loispostula loispostula force-pushed the fix/8339-pyproject-uv-lock branch from 3e808a6 to 136b511 Compare April 10, 2026 18:58
@olblak olblak enabled auto-merge (squash) April 10, 2026 19:15
@olblak olblak merged commit 6330994 into updatecli:main Apr 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pyproject autodiscovery: uv add rewrites pyproject.toml instead of only updating uv.lock

2 participants