Skip to content

Commit 3418149

Browse files
check if current_type is AnyType
1 parent fd29b4d commit 3418149

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

mypy/checker.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8018,20 +8018,19 @@ def conditional_types(
80188018
# attempt to narrow anything. Instead, we broaden the expr to Any to
80198019
# avoid false positives
80208020
return proposed_type, default
8021-
elif not any( # handle concrete subtypes
8021+
elif not any(
80228022
type_range.is_upper_bound for type_range in proposed_type_ranges
8023-
) and is_proper_subtype(current_type, proposed_type, ignore_promotions=True):
8024-
# Expression is always of one of the types in proposed_type_ranges
8025-
return default, UninhabitedType()
8026-
elif not any( # handle structural subtypes
8027-
type_range.is_upper_bound for type_range in proposed_type_ranges
8028-
) and (
8029-
is_subtype(current_type, proposed_type, ignore_promotions=True)
8030-
and (
8031-
isinstance(proposed_type, CallableType)
8032-
or (isinstance(proposed_type, Instance) and proposed_type.type.is_protocol)
8023+
) and ( # concrete subtypes
8024+
is_proper_subtype(current_type, proposed_type, ignore_promotions=True)
8025+
or ( # structural subtypes
8026+
is_subtype(current_type, proposed_type, ignore_promotions=True)
8027+
and (
8028+
isinstance(proposed_type, CallableType)
8029+
or (isinstance(proposed_type, Instance) and proposed_type.type.is_protocol)
8030+
)
80338031
)
80348032
):
8033+
# Expression is always of one of the types in proposed_type_ranges
80358034
return default, UninhabitedType()
80368035
elif not is_overlapping_types(current_type, proposed_type, ignore_promotions=True):
80378036
# Expression is never of any type in proposed_type_ranges

0 commit comments

Comments
 (0)