Fix lock --check falsely reporting stale when newer versions available#2331
Open
petrkalos wants to merge 1 commit into
Open
Fix lock --check falsely reporting stale when newer versions available#2331petrkalos wants to merge 1 commit into
petrkalos wants to merge 1 commit into
Conversation
…lable Pre-seed the temp output file with existing lock content before calling uv pip compile, so uv's default pin-preservation behavior keeps pinned versions that still satisfy the declared requirements. Previously, in_sync() wrote to an empty temp file, causing uv to resolve from scratch and pick the latest versions — making --check fail whenever any dependency had a newer release available.
e573b49 to
1176ea5
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
hatch env lock --check(andhatch dep lock --check) incorrectly reports "Lockfile is not up to date" when a dependency has a newer version available on PyPI, even though the existing lock still satisfies all declared requirements.UvLocker.in_sync()regenerates the lockfile into an empty temp file. Sinceuv pip compilehas no existing pins to read from that empty file, it resolves from scratch and picks the latest versions — producing a diff whenever any package has a newer release.generate(). This leveragesuv pip compile's default pin-preservation behavior (it reads pins from--output-fileand keeps them when they satisfy the requirements). The check now only fails when inputs actually changed (new deps added, version ranges tightened, deps removed).Test plan
test_uv_in_sync_preserves_pins_from_existing_lock— verifies temp file is pre-seeded so generate() can preserve pinstest_uv_in_sync_detects_stale_when_inputs_change— verifies that genuinely stale locks (e.g., range tightened beyond pinned version) are still detectedtest_check_does_not_fail_when_newer_version_available— end-to-end with real uv: locksurllib3==2.0.0, widens to>=1.26, confirms--checkpasses