fix(solver): prune sibling deps disjoint with override marker context#10944
Open
dimbleby wants to merge 1 commit into
Open
fix(solver): prune sibling deps disjoint with override marker context#10944dimbleby wants to merge 1 commit into
dimbleby wants to merge 1 commit into
Conversation
When the solver retries under an override branch for a duplicate dependency, sibling dependencies whose markers are disjoint with the override's effective marker context were still considered. Their transitive constraints then spuriously conflicted with the overridden constraint, causing resolution to fail even when a valid solution existed (e.g. a transitive dep pinning a different version of the overridden package on a marker branch that does not apply). Extend the existing overrides_marker_intersection mechanism into complete_package so such siblings are pruned during the solve phase, mirroring the filter already applied to duplicate deps. Fixes python-poetry#5506. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
complete_package, the new marker-pruning logic relies onself._overrides_marker_intersectionalways being a meaningful context; consider either explicitly guarding this with an "in override" condition or asserting/documenting what the default intersection represents when not in an override branch so future changes don't break this assumption. - The comment above the new
if self._overrides_marker_intersection.intersect(dep.marker).is_empty():check describes behavior "when solving under an override" but the code runs unconditionally; aligning the implementation with the comment (or clarifying the comment) would make the control flow and intent easier to follow.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `complete_package`, the new marker-pruning logic relies on `self._overrides_marker_intersection` always being a meaningful context; consider either explicitly guarding this with an "in override" condition or asserting/documenting what the default intersection represents when not in an override branch so future changes don't break this assumption.
- The comment above the new `if self._overrides_marker_intersection.intersect(dep.marker).is_empty():` check describes behavior "when solving under an override" but the code runs unconditionally; aligning the implementation with the comment (or clarifying the comment) would make the control flow and intent easier to follow.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Another one that looks plausible, has a convincing testcase, is probably right...
When the solver retries under an override branch for a duplicate dependency, sibling dependencies whose markers are disjoint with the override's effective marker context were still considered. Their transitive constraints then spuriously conflicted with the overridden constraint, causing resolution to fail even when a valid solution existed (e.g. a transitive dep pinning a different version of the overridden package on a marker branch that does not apply).
Extend the existing overrides_marker_intersection mechanism into complete_package so such siblings are pruned during the solve phase, mirroring the filter already applied to duplicate deps.
Fixes #5506.