Skip to content

Commit 240a368

Browse files
authored
Fix constraint union treating "not in" same as "!=" (#925)
1 parent b959f87 commit 240a368

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/poetry/core/constraints/generic/constraint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def union(self, other: BaseConstraint) -> BaseConstraint:
180180

181181
ops = {self.operator, other.operator}
182182
if (
183-
(ops in ({"!="}, {"not in"}))
183+
ops == {"!="}
184184
or (
185185
(
186186
ops in ({"in", "!="}, {"in", "not in"})

tests/constraints/generic/test_constraint.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,15 @@ def test_intersect_extra(
12031203
(
12041204
Constraint("tegra", "not in"),
12051205
Constraint("rpi", "not in"),
1206-
AnyConstraint(),
1206+
# NB not AnyConstraint - eg "tegra-rpi" does not satisfy either constraint
1207+
(
1208+
UnionConstraint(
1209+
Constraint("tegra", "not in"), Constraint("rpi", "not in")
1210+
),
1211+
UnionConstraint(
1212+
Constraint("rpi", "not in"), Constraint("tegra", "not in")
1213+
),
1214+
),
12071215
),
12081216
(
12091217
Constraint("tegra", "in"),

0 commit comments

Comments
 (0)