Skip to content

Commit e80d658

Browse files
Update mypy/checker.py
Co-authored-by: Stanislav Terliakov <[email protected]>
1 parent a3d469f commit e80d658

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

mypy/checker.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8022,14 +8022,16 @@ def conditional_types(
80228022
return proposed_type, default
80238023
elif not any(
80248024
type_range.is_upper_bound for type_range in proposed_type_ranges
8025-
) and ( # concrete subtypes
8025+
) and (
8026+
# concrete subtypes
80268027
is_proper_subtype(current_type, proposed_type, ignore_promotions=True)
8027-
or ( # structural subtypes
8028-
is_subtype(current_type, proposed_type, ignore_promotions=True)
8029-
and (
8028+
# structural subtypes
8029+
or (
8030+
(
80308031
isinstance(proposed_type, CallableType)
80318032
or (isinstance(proposed_type, Instance) and proposed_type.type.is_protocol)
80328033
)
8034+
and is_subtype(current_type, proposed_type, ignore_promotions=True)
80338035
)
80348036
):
80358037
# Expression is always of one of the types in proposed_type_ranges

0 commit comments

Comments
 (0)