@@ -3468,7 +3468,7 @@ def visit_op_expr(self, e: OpExpr) -> Type:
3468
3468
# It's actually a type expression X | Y.
3469
3469
return self .accept (e .analyzed )
3470
3470
if e .op == "and" or e .op == "or" :
3471
- return self .check_boolean_op (e , e )
3471
+ return self .check_boolean_op (e )
3472
3472
if e .op == "*" and isinstance (e .left , ListExpr ):
3473
3473
# Expressions of form [...] * e get special type inference.
3474
3474
return self .check_list_multiply (e )
@@ -4255,20 +4255,18 @@ def check_op(
4255
4255
context = context ,
4256
4256
)
4257
4257
4258
- def check_boolean_op (self , e : OpExpr , context : Context ) -> Type :
4258
+ def check_boolean_op (self , e : OpExpr ) -> Type :
4259
4259
"""Type check a boolean operation ('and' or 'or')."""
4260
4260
4261
4261
# A boolean operation can evaluate to either of the operands.
4262
4262
4263
- # We use the current type context to guide the type inference of of
4263
+ # We use the current type context to guide the type inference of
4264
4264
# the left operand. We also use the left operand type to guide the type
4265
4265
# inference of the right operand so that expressions such as
4266
4266
# '[1] or []' are inferred correctly.
4267
4267
ctx = self .type_context [- 1 ]
4268
4268
left_type = self .accept (e .left , ctx )
4269
- expanded_left_type = try_expanding_sum_type_to_union (
4270
- self .accept (e .left , ctx ), "builtins.bool"
4271
- )
4269
+ expanded_left_type = try_expanding_sum_type_to_union (left_type , "builtins.bool" )
4272
4270
4273
4271
assert e .op in ("and" , "or" ) # Checked by visit_op_expr
4274
4272
0 commit comments