feat: support uv.lock files in the Python strategy#2693
Open
jlopez wants to merge 4 commits intogoogleapis:mainfrom
Open
feat: support uv.lock files in the Python strategy#2693jlopez wants to merge 4 commits intogoogleapis:mainfrom
jlopez wants to merge 4 commits intogoogleapis:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Automatically update the project's entry in uv.lock when releasing a Python package, without requiring extra-files configuration. Closes googleapis#2561
- Warn when target package is not found in uv.lock (silent no-op bug) - Add comment explaining warn-not-throw vs CargoLock for empty lockfiles - Add comment explaining double-parse is inherent to replaceTomlValue API - Add test for uv.lock with no [[package]] entries (100% coverage) - Add test for target package not found in lockfile - Add tests for PEP 503 underscore/dot normalization
- Distinguish virtual packages (present but version-less) from absent packages: emit a dedicated warning instead of the misleading "not found" message (fixes false debugging trail in uv mono-repos) - Rename test 'silently skips packages without a version field' to accurately reflect that a warning is now emitted; add logger spy to assert the warning text - Assert uv.lock is included in updates for 'builds common files' and 'omits changelog if skipChangelog=true' strategy tests, catching any regression that moves the uv.lock push inside the pyproject.toml branch - Correct PEP 508 → PEP 503 in normalizePackageName docstring (PEP 503 is the authoritative spec for canonical name normalisation) - Document that replaceTomlValue may throw on a malformed lockfile
e3e4f65 to
14e4658
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2561
The Python strategy now automatically updates the project's entry in
uv.lockwhen cutting a release, without requiring anyextra-filesconfiguration.What changed
UvLockupdater (src/updaters/python/uv-lock.ts) — mirrors the existingCargoLockpattern: parses the lockfile, finds the matching[[package]]entry by name, and usesreplaceTomlValue()to update the version while preserving all formatting and comments.Pythonstrategy (src/strategies/python.ts) — addsuv.locktobuildUpdates()alongside the other Python files. Gated onprojectNamebeing known (same condition as__init__.pyupdates).createIfMissing: falsemakes it a safe no-op for projects that don't use uv.My_Package→my-package) so names are compared case-insensitively with-,_, and.treated as equivalent.versionfield) are skipped with a specific warning distinguishing them from packages that are genuinely absent from the lockfile.Test plan
test/updaters/uv-lock.ts— unit tests covering: version update with formatting preserved (snapshot), PEP 503 name normalization (case, underscores, dots), virtual package warning, not touching unrelated dependencies, empty lockfile, missing packagetest/strategies/python.ts— assertsuv.lockappears in the update list for both the common-files and skip-changelog paths, in addition to whenpyproject.tomlis presentnpm test— all passing, 0 failing🤖 Generated with Claude Code