(self, name: ast.NamedExpr)
| 964 | return self.statements |
| 965 | |
| 966 | def visit_NamedExpr(self, name: ast.NamedExpr) -> tuple[ast.NamedExpr, str]: |
| 967 | # This method handles the 'walrus operator' repr of the target |
| 968 | # name if it's a local variable or _should_repr_global_name() |
| 969 | # thinks it's acceptable. |
| 970 | locs = ast.Call(self.builtin("locals"), [], []) |
| 971 | target_id = name.target.id |
| 972 | inlocs = ast.Compare(ast.Constant(target_id), [ast.In()], [locs]) |
| 973 | dorepr = self.helper("_should_repr_global_name", name) |
| 974 | test = ast.BoolOp(ast.Or(), [inlocs, dorepr]) |
| 975 | expr = ast.IfExp(test, self.display(name), ast.Constant(target_id)) |
| 976 | return name, self.explanation_param(expr) |
| 977 | |
| 978 | def visit_Name(self, name: ast.Name) -> tuple[ast.Name, str]: |
| 979 | # Display the repr of the name if it's a local variable or |
nothing calls this directly
no test coverage detected