fix Constraint.allows_any() wrong for in/not in with compound constraints by dimbleby · Pull Request #927 · python-poetry/poetry-core (original) (raw)

[sourcery-ai[bot]](/apps/sourcery-ai)

Bot reviewed Mar 21, 2026

@radoering radoering changed the titlefix Constraint.allows_any() wrong for in/not in with compound constra… fix Constraint.allows_any() wrong for in/not in with compound constraints

Mar 28, 2026

radoering

@dimbleby @radoering

…ints

Constraint.allows_any() only returned True for the '!=' operator when the other argument was a MultiConstraint or UnionConstraint. This caused incorrect False results for 'in' and 'not in' operators.

For MultiConstraint (AND): check that self is compatible with each individual constraint via all(self.allows_any(c) ...).

For UnionConstraint (OR): check if self overlaps any member via any(self.allows_any(c) ...).

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

@pre-commit-ci @radoering

@dimbleby dimbleby deleted the fix/constraint-allows-any-compound branch

March 28, 2026 08:01

This was referenced

Mar 29, 2026

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

[ Show hidden characters]({{ revealButtonHref }})