Merged
Conversation
Without this change the intersection of `extra == "a" and extra == "b"` and `extra == "a" or extra == "b"` is `extra == "a" and extra == "b" and (extra == "a" or extra == "b")`. With the change, it is simplified to `extra == "a" and extra == "b"`.
Reviewer's Guide by SourceryThis pull request simplifies the intersection logic for Sequence diagram for intersecting UnionConstraint and MultiConstraintsequenceDiagram
participant UC as UnionConstraint
participant MC as MultiConstraint
participant C1 as Constraint1
participant C2 as Constraint2
participant C3 as Constraint3
UC->MC: intersect(other: MultiConstraint)
loop for each our_constraint in UC
UC->C1: our_constraint
C1->C2: intersect(their_constraint)
C2->C3: intersect(their_constraint)
C1->UC: intersection
UC->UC: add_unseen_constraint(intersection)
alt intersection is not empty and not seen
UC->UC: new_constraints.append(intersection)
end
end
UC->MC: return new UnionConstraint(new_constraints)
Updated class diagram for UnionConstraint and MultiConstraintclassDiagram
class BaseConstraint {
<<Abstract>>
}
class UnionConstraint {
-List~BaseConstraint~ _constraints
+intersect(other: BaseConstraint): BaseConstraint
-add_unseen_constraint(constraint: BaseConstraint): void
}
class MultiConstraint {
-List~BaseConstraint~ constraints
+intersect(other: BaseConstraint): BaseConstraint
}
class EmptyConstraint {
}
BaseConstraint <|-- UnionConstraint
BaseConstraint <|-- MultiConstraint
BaseConstraint <|-- EmptyConstraint
UnionConstraint o-- BaseConstraint : contains
MultiConstraint o-- BaseConstraint : contains
note for UnionConstraint "The intersect method is updated to avoid duplicate constraints"
note for UnionConstraint "The add_unseen_constraint method is added to avoid duplicate constraints"
File-Level Changes
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 - here's some feedback:
Overall Comments:
- The
add_unseen_constraintfunction is a good way to avoid code duplication. - Consider extracting the intersection logic into a separate function for better readability.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
2 tasks
abn
approved these changes
Feb 23, 2025
This was referenced Mar 29, 2025
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.
Without this change the intersection of
extra == "a" and extra == "b"andextra == "a" or extra == "b"isextra == "a" and extra == "b" and (extra == "a" or extra == "b"). With the change, it is simplified toextra == "a" and extra == "b".Related to: python-poetry/poetry#10195
Summary by Sourcery
Simplifies the intersection logic for union and multi constraints, particularly when dealing with extra markers, to produce cleaner and more concise expressions. Adds new test cases to ensure the correctness of the intersection logic.
Bug Fixes:
Tests: