-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simplify extra markers #842
simplify extra markers #842
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @radoering - I've reviewed your changes - here's some feedback:
Overall Comments:
- The
add_unseen_constraint
function 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.
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: