(self, o: WhileStmt)
| 601 | self.tracker.in_finally = False |
| 602 | |
| 603 | def visit_while_stmt(self, o: WhileStmt) -> None: |
| 604 | o.expr.accept(self) |
| 605 | self.tracker.start_branch_statement() |
| 606 | loop = Loop() |
| 607 | self.loops.append(loop) |
| 608 | o.body.accept(self) |
| 609 | has_break = loop.has_break |
| 610 | if not checker.is_true_literal(o.expr): |
| 611 | # If this is a loop like `while True`, we can consider the body to be |
| 612 | # a single branch statement (we're guaranteed that the body is executed at least once). |
| 613 | # If not, call next_branch() to make all variables defined there conditional. |
| 614 | self.tracker.next_branch() |
| 615 | self.tracker.end_branch_statement() |
| 616 | if o.else_body is not None: |
| 617 | # If the loop has a `break` inside, `else` is executed conditionally. |
| 618 | # If the loop doesn't have a `break` either the function will return or |
| 619 | # execute the `else`. |
| 620 | if has_break: |
| 621 | self.tracker.start_branch_statement() |
| 622 | self.tracker.next_branch() |
| 623 | if o.else_body: |
| 624 | o.else_body.accept(self) |
| 625 | if has_break: |
| 626 | self.tracker.end_branch_statement() |
| 627 | self.loops.pop() |
| 628 | |
| 629 | def visit_as_pattern(self, o: AsPattern) -> None: |
| 630 | if o.name is not None: |
nothing calls this directly
no test coverage detected