The with visiting method for tirx. Parameters ---------- self : Parser The visiting parser. node : doc.With The doc AST with node.
(self: Parser, node: doc.With)
| 567 | |
| 568 | @dispatch.register(token="tirx", type_name="With") |
| 569 | def visit_with(self: Parser, node: doc.With) -> None: |
| 570 | """The with visiting method for tirx. |
| 571 | |
| 572 | Parameters |
| 573 | ---------- |
| 574 | self : Parser |
| 575 | The visiting parser. |
| 576 | |
| 577 | node : doc.With |
| 578 | The doc AST with node. |
| 579 | """ |
| 580 | with contextlib.ExitStack() as stack: |
| 581 | stack.enter_context(self.var_table.with_frame()) |
| 582 | for item in node.items: |
| 583 | frame = self.eval_expr(item.context_expr) |
| 584 | if not isinstance(frame, Frame) and not ( |
| 585 | hasattr(frame, "__enter__") and hasattr(frame, "__exit__") |
| 586 | ): |
| 587 | self.report_error( |
| 588 | item.context_expr, |
| 589 | "Invalid context expression in the with-statement.", |
| 590 | ) |
| 591 | rhs = stack.enter_context(frame) |
| 592 | if item.optional_vars is not None: |
| 593 | self.eval_assign(target=item.optional_vars, source=rhs, bind_value=bind_with_value) |
| 594 | self.visit_body(node.body) |
| 595 | |
| 596 | |
| 597 | @dispatch.register(token="tirx", type_name="FunctionDef") |
nothing calls this directly
no test coverage detected
searching dependent graphs…