Skip to content

Commit f41a44b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent aa7b7c4 commit f41a44b

File tree

1 file changed

+15
-28
lines changed

1 file changed

+15
-28
lines changed

mypy/checker.py

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6794,9 +6794,7 @@ def narrow_type_by_identity_equality(
67946794
# they create the actual ambiguity with StrEnum/IntEnum.
67956795
# We use the original (unexpanded) type to preserve StrEnum
67966796
# type information during union simplification.
6797-
orig_expr_type = get_proper_type(
6798-
coerce_to_literal(operand_types[i])
6799-
)
6797+
orig_expr_type = get_proper_type(coerce_to_literal(operand_types[i]))
68006798
if isinstance(orig_expr_type, UnionType):
68016799
# First check if there are any narrowable items
68026800
# (precise non-enum types like Literal or None).
@@ -6808,9 +6806,7 @@ def narrow_type_by_identity_equality(
68086806
item_keys = ambiguous_enum_equality_keys(item)
68096807
is_enum_side = bool(item_keys - {"<other>"})
68106808
p_item = get_proper_type(item)
6811-
if not is_enum_side and isinstance(
6812-
p_item, (LiteralType, NoneType)
6813-
):
6809+
if not is_enum_side and isinstance(p_item, (LiteralType, NoneType)):
68146810
has_narrowable = True
68156811
break
68166812
if has_narrowable:
@@ -6820,30 +6816,25 @@ def narrow_type_by_identity_equality(
68206816
item_keys = ambiguous_enum_equality_keys(item)
68216817
is_enum_side = bool(item_keys - {"<other>"})
68226818
p_item = get_proper_type(item)
6823-
can_narrow = (
6824-
not is_enum_side
6825-
and isinstance(p_item, (LiteralType, NoneType))
6819+
can_narrow = not is_enum_side and isinstance(
6820+
p_item, (LiteralType, NoneType)
68266821
)
68276822
if can_narrow:
68286823
item_type = coerce_to_literal(
68296824
try_expanding_sum_type_to_union(item, None)
68306825
)
68316826
target = TypeRange(target_type, is_upper_bound=False)
6832-
item_if_map, item_else_map = (
6833-
conditional_types_to_typemaps(
6834-
operands[i],
6835-
*conditional_types(
6836-
item_type,
6837-
[target],
6838-
default=item_type,
6839-
from_equality=True,
6840-
),
6841-
)
6827+
item_if_map, item_else_map = conditional_types_to_typemaps(
6828+
operands[i],
6829+
*conditional_types(
6830+
item_type,
6831+
[target],
6832+
default=item_type,
6833+
from_equality=True,
6834+
),
68426835
)
68436836
or_if_maps.append(item_if_map)
6844-
if is_target_for_value_narrowing(
6845-
get_proper_type(target_type)
6846-
):
6837+
if is_target_for_value_narrowing(get_proper_type(target_type)):
68476838
or_else_maps.append(item_else_map)
68486839
else:
68496840
# Non-value target (e.g. str): we can't
@@ -6853,12 +6844,8 @@ def narrow_type_by_identity_equality(
68536844
else:
68546845
or_if_maps.append({operands[i]: item})
68556846
or_else_maps.append({operands[i]: item})
6856-
all_if_maps.append(
6857-
reduce_or_conditional_type_maps(or_if_maps)
6858-
)
6859-
all_else_maps.append(
6860-
reduce_or_conditional_type_maps(or_else_maps)
6861-
)
6847+
all_if_maps.append(reduce_or_conditional_type_maps(or_if_maps))
6848+
all_else_maps.append(reduce_or_conditional_type_maps(or_else_maps))
68626849
continue
68636850

68646851
target = TypeRange(target_type, is_upper_bound=False)

0 commit comments

Comments
 (0)