Skip to content

Commit 948347c

Browse files
committed
Restore recursive types treatment
1 parent 09498fb commit 948347c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

mypy/constraints.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,15 @@ def _infer_constraints(
411411
# When the template is a union, we are okay with leaving some
412412
# type variables indeterminate. This helps with some special
413413
# cases, though this isn't very principled.
414-
result = any_constraints(
414+
if has_recursive_types(template) and not has_recursive_types(actual):
415+
return handle_recursive_union(template, actual, direction)
416+
return any_constraints(
415417
[
416418
infer_constraints_if_possible(t_item, actual, direction)
417419
for t_item in template.items
418420
],
419421
eager=isinstance(actual, AnyType),
420422
)
421-
if result:
422-
return result
423-
elif has_recursive_types(template) and not has_recursive_types(actual):
424-
return handle_recursive_union(template, actual, direction)
425-
return []
426423

427424
# Remaining cases are handled by ConstraintBuilderVisitor.
428425
return template.accept(ConstraintBuilderVisitor(actual, direction, skip_neg_op))

0 commit comments

Comments
 (0)