fix calculated markers if a dependency is required by several groups with different markers#10613
Merged
radoering merged 1 commit intopython-poetry:mainfrom Nov 15, 2025
Conversation
Reviewer's GuideEnhance marker propagation to handle dependencies required by multiple groups or extras by tracking markers per group set and merging them in depth-first traversal and calculation phases, with accompanying tests. Class diagram for updated marker tracking in dependency graphclassDiagram
class Solver {
}
class PackageNode {
+package: Package
+groups: frozenset[NormalizedName]
+marker: BaseMarker
+reachable(): list[PackageNode]
}
class Package {
}
class BaseMarker {
+union(other: BaseMarker): BaseMarker
+intersect(other: BaseMarker): BaseMarker
+without_extras(): BaseMarker
}
class EmptyMarker {
}
class MarkerOriginDict {
<<defaultdict>>
+[child_package][parent_package][groups]: BaseMarker
}
Solver --> MarkerOriginDict
PackageNode --> Package
PackageNode --> BaseMarker
BaseMarker <|-- EmptyMarker
MarkerOriginDict o-- Package
MarkerOriginDict o-- BaseMarker
Flow diagram for marker propagation in depth-first search and calculationflowchart TD
A["Start DFS traversal"] --> B["For each out_neighbor in node.reachable()"]
B --> C["Get groups for out_neighbor"]
C --> D["Retrieve previous marker for (child, parent, groups)"]
D --> E["Compute new marker (with or without extras)"]
E --> F["Update markers[child][parent][groups] with union"]
F --> G["Continue DFS visit"]
G --> H["Insert node in sorted list"]
H --> I["Calculate markers phase"]
I --> J["For each package, for each parent, for each group set"]
J --> K["If parent has groups, merge/intersect per-group markers"]
J --> L["If parent is root, add edge marker to corresponding child groups"]
K --> M["Update transitive_marker for each group"]
L --> M
M --> N["Assign transitive_marker to package info"]
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 there - 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> `src/poetry/puzzle/solver.py:281-282` </location>
<code_context>
back_edges[out_neighbor.id].append(node)
- marker = markers[out_neighbor.package][node.package]
- markers[out_neighbor.package][node.package] = marker.union(
+ groups = out_neighbor.groups
+ prev_marker = markers[out_neighbor.package][node.package][groups]
+ new_marker = (
out_neighbor.marker
</code_context>
<issue_to_address>
**issue (bug_risk):** Using frozenset as a key for groups may lead to subtle bugs if group sets are not canonicalized.
Inconsistent construction of frozenset keys can cause missed updates or incorrect unions. Make sure group sets are always built in a consistent, canonical way before use.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…with different markers This also fixes the case where a dependency is required in an extra and a group.
c120bad to
9078783
Compare
|
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.
This also fixes the case where a dependency is required in an extra and a group.
Pull Request Check List
Summary by Sourcery
Improve marker calculation to correctly handle dependencies required by multiple groups or extras by grouping edge-specific markers and updating both DFS and transitive marker aggregation
Bug Fixes:
Enhancements:
Tests: