@@ -8018,20 +8018,19 @@ def conditional_types(
8018
8018
# attempt to narrow anything. Instead, we broaden the expr to Any to
8019
8019
# avoid false positives
8020
8020
return proposed_type , default
8021
- elif not any ( # handle concrete subtypes
8021
+ elif not any (
8022
8022
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
+ )
8033
8031
)
8034
8032
):
8033
+ # Expression is always of one of the types in proposed_type_ranges
8035
8034
return default , UninhabitedType ()
8036
8035
elif not is_overlapping_types (current_type , proposed_type , ignore_promotions = True ):
8037
8036
# Expression is never of any type in proposed_type_ranges
0 commit comments