fix(pypi): preserve real version for URL-pinned pip deps on re-lock - #923
Open
thomas-dresselhaus wants to merge 1 commit into
Open
fix(pypi): preserve real version for URL-pinned pip deps on re-lock#923thomas-dresselhaus wants to merge 1 commit into
thomas-dresselhaus wants to merge 1 commit into
Conversation
`get_package` reconstructs an already-locked dependency into a Poetry package during the reconcile solve (`--update`, or a changed input under `--check-input-hash`). For URL-sourced deps it hard-coded `version="0.0.0"`, discarding the real version in `locked.version`. When another package constrains the URL-pinned dep by version, holding it at `0.0.0` corrupts the reconcile: the solver either silently downgrades the constraining packages to ancient versions (emitting the URL dep as `0.0.0`), or fails with a `SolverProblemError` when no downgrade is possible. A first-time lock is unaffected because the URL dep is resolved fresh. Use `locked.version`, matching the non-URL `else` branch, while keeping the URL pin intact. A LockedDependency's source is always a URL source (`DependencySource.type` is `Literal["url"]`), so no gating is needed. Adds a deterministic regression test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for conda-lock ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Description
Fixes #922.
get_packagereconstructs a Poetry package from an already-locked dependency during a re-lock (thereconcile solve). For URL-sourced deps it hard-coded
version="0.0.0", discarding the real versionstored in
locked.version.That placeholder breaks the reconcile whenever another package constrains the URL-pinned dep by
version (e.g. a transitive
foo >=1.0): the solver either silently downgrades the constrainingpackages to ancient versions (and emits the URL dep as
0.0.0), or fails outright with aSolverProblemErrorwhen no downgrade is possible. A first-time lock is unaffected (the URL dep isresolved fresh); only reconciliation (
--update, or a changed input under--check-input-hash)hits it.
This uses
locked.version— matching the non-URLelsebranch in the same function — whileleaving the URL pin (
source_type/source_url) intact. ALockedDependency'ssourceis always aURL source (
DependencySource.typeisLiteral["url"]), so no source-type gating is needed.(Prepared with AI assistance.) 🤖
Change —
conda_lock/pypi_solver.pydef get_package(locked: LockedDependency) -> PoetryPackage: if locked.source is not None: return PoetryPackage( locked.name, source_type="url", source_url=locked.source.url, - version="0.0.0", + version=locked.version, ) else: return PoetryPackage(locked.name, version=locked.version)Test —
tests/test_conda_lock.pyA deterministic, network-free regression test pinning the defect (fails pre-fix with
0.0.0,passes post-fix), asserting both the version and the preserved URL pin:
Notes for maintainers
SolverProblemError) needs a graph with atransitive version constraint on the URL-pinned dep; the minimal case is
idna @ <url>+requests, locked then re-locked. I kept the committed regression test at the unit level (nonetwork, deterministic) since that's the smallest reliable gate; happy to add an integration
fixture if you'd prefer one.
🤖 Generated with Claude Code