@@ -532,7 +532,8 @@ def any_constraints(options: list[list[Constraint] | None], *, eager: bool) -> l
532532 # Multiple sets of constraints that are all the same. Just pick any one of them.
533533 return valid_options [0 ]
534534
535- if all (is_similar_constraints (valid_options [0 ], c ) for c in valid_options [1 :]):
535+ all_similar = all (is_similar_constraints (valid_options [0 ], c ) for c in valid_options [1 :])
536+ if all_similar :
536537 # All options have same structure. In this case we can merge-in trivial
537538 # options (i.e. those that only have Any) and try again.
538539 trivial_options = select_trivial (valid_options )
@@ -543,10 +544,6 @@ def any_constraints(options: list[list[Constraint] | None], *, eager: bool) -> l
543544 continue
544545 merged_options .append ([merge_with_any (c ) for c in option ])
545546 return any_constraints (list (merged_options ), eager = eager )
546- # Solver will apply meets and joins as necessary, return everything we know.
547- # Just deduplicate to reduce the amount of work.
548- all_combined = sum (valid_options , [])
549- return list (dict .fromkeys (all_combined ))
550547
551548 # If normal logic didn't work, try excluding trivially unsatisfiable constraint (due to
552549 # upper bounds) from each option, and comparing them again.
@@ -562,6 +559,13 @@ def any_constraints(options: list[list[Constraint] | None], *, eager: bool) -> l
562559 if filtered_options != options :
563560 return any_constraints (filtered_options , eager = eager )
564561
562+ if all_similar :
563+ # Now we know all constraints might be satisfiable and have similar structure.
564+ # Solver will apply meets and joins as necessary, return everything we know.
565+ # Just deduplicate to reduce the amount of work.
566+ all_combined = sum (valid_options , [])
567+ return list (dict .fromkeys (all_combined ))
568+
565569 # Otherwise, there are either no valid options or multiple, inconsistent valid
566570 # options. Give up and deduce nothing.
567571 return []
0 commit comments