solver: fix dependency resolution for self-referential extras with duplicate dependencies#10488
Merged
radoering merged 1 commit intopython-poetry:mainfrom Aug 4, 2025
Conversation
…plicate dependencies
Reviewer's GuideThis PR adds a merge_extras flag to the package factory to control merging of optional self-referential dependencies, updates tests to parameterize and validate both merged and unmerged scenarios with duplicate extras, and adjusts the solver provider to use deduplicated extras sets when resolving overlapping markers. Class diagram for updated dependency resolution in ProviderclassDiagram
class Provider {
_active_root_extras
complete_package(package, dependency, ...)
_resolve_overlapping_markers(package, deps, active_extras)
}
class Package {
is_root()
}
class Dependency {
extras
}
Provider --> Package : uses
Provider --> Dependency : uses
Provider : +complete_package() now uses found_extras instead of dependency.extras for non-root
Class diagram for PackageFactory with merge_extras flagclassDiagram
class PackageFactory {
merge_extras : bool
create_package(...)
}
PackageFactory : +merge_extras flag controls merging of self-referential extras
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @radoering - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `tests/puzzle/test_solver.py:597` </location>
<code_context>
"py310": ["py310-package ; python_version > '3.8'"],
- "all": ["a[download,install]"],
+ "all": ["a[download,download2,install]"],
"py": ["a[py38,py310]"],
"nested": ["a[all]"],
},
</code_context>
<issue_to_address>
Missing test for conflicting or overlapping markers in extras.
Please add a test where two extras reference the same dependency with different markers to verify correct marker merging and dependency resolution.
</issue_to_address>
### Comment 2
<location> `tests/puzzle/test_solver.py:598` </location>
<code_context>
- "all": ["a[download,install]"],
+ "all": ["a[download,download2,install]"],
"py": ["a[py38,py310]"],
"nested": ["a[all]"],
},
+ merge_extras=merge_extras,
</code_context>
<issue_to_address>
Consider adding a test for circular or deeply nested extras.
Adding a test for circular references between extras (e.g., 'a[foo]' includes 'a[bar]' and vice versa) would help verify that the resolver handles such cases without infinite loops or incorrect resolutions.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Pull Request Check List
Resolves: #10434
Summary by Sourcery
Fix solver dependency resolution for self-referential extras containing duplicate dependencies and extend test fixtures to cover merged extra markers
Enhancements:
Tests: