@@ -1014,20 +1014,15 @@ def visit_BoolOp(self, boolop: ast.BoolOp) -> tuple[ast.Name, str]:
10141014 # cond is set in a prior loop iteration below
10151015 self .expl_stmts .append (ast .If (cond , fail_inner , [])) # noqa: F821
10161016 self .expl_stmts = fail_inner
1017- # Check if the left operand is a ast.NamedExpr and the value has already been visited
1018- if (
1019- isinstance (v , ast .Compare )
1020- and isinstance (v .left , ast .NamedExpr )
1021- and v .left .target .id
1022- in [
1023- ast_expr .id
1024- for ast_expr in boolop .values [:i ]
1025- if hasattr (ast_expr , "id" )
1026- ]
1027- ):
1028- pytest_temp = self .variable ()
1029- self .variables_overwrite [self .scope ][v .left .target .id ] = v .left # type:ignore[assignment]
1030- v .left .target .id = pytest_temp
1017+ match v :
1018+ # Check if the left operand is an ast.NamedExpr and the value has already been visited
1019+ case ast .Compare (left = ast .NamedExpr (target = ast .Name (id = target_id ))):
1020+ if target_id in [
1021+ e .id for e in boolop .values [:i ] if isinstance (e , ast .Name )
1022+ ]:
1023+ pytest_temp = self .variable ()
1024+ self .variables_overwrite [self .scope ][target_id ] = v .left # type:ignore[assignment]
1025+ v .left .target .id = pytest_temp
10311026 self .push_format_context ()
10321027 res , expl = self .visit (v )
10331028 body .append (ast .Assign ([ast .Name (res_var , ast .Store ())], res ))
0 commit comments