Skip to content

Commit 25fc1e8

Browse files
refactor(rewrite): drop the walrus snapshot visit_Compare no longer needs
visit_operand freezes a walrus operand whenever anything follows it, and a comparison always has at least one comparator -- so by the time visit_Compare looks at its left operand, a NamedExpr has already been copied into a temporary. The special case that did it here can never run. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent bfc06c7 commit 25fc1e8

1 file changed

Lines changed: 0 additions & 2 deletions

File tree

‎src/_pytest/assertion/rewrite.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,8 +1164,6 @@ def visit_Compare(self, comp: ast.Compare) -> tuple[ast.expr, str]:
11641164
left_res, left_expl = self.visit_operand(comp.left, comp.comparators)
11651165
if isinstance(comp.left, ast.Compare | ast.BoolOp):
11661166
left_expl = f"({left_expl})"
1167-
if isinstance(left_res, ast.NamedExpr):
1168-
left_res = self.assign(left_res)
11691167
res_variables = [self.variable() for i in range(len(comp.ops))]
11701168
load_names: list[ast.expr] = [ast.Name(v, ast.Load()) for v in res_variables]
11711169
store_names = [ast.Name(v, ast.Store()) for v in res_variables]

0 commit comments

Comments
 (0)