| 667 | return ParseResult(violations=violations) |
| 668 | |
| 669 | def parse_setup(self, body: PeekStack[Node]) -> ParseResult[SetupCell]: |
| 670 | # setup? = Async?With(kwargs*, stmt*) |
| 671 | violations: list[Violation] = [] |
| 672 | node = body.last |
| 673 | maybe_setup = node |
| 674 | while node: |
| 675 | if is_cell(maybe_setup := body.peek()): |
| 676 | break |
| 677 | node = next(body) |
| 678 | if not node: |
| 679 | return ParseResult(violations=violations) |
| 680 | violations.append( |
| 681 | Violation( |
| 682 | UNEXPECTED_STATEMENT_CELL_DEF_VIOLATION, |
| 683 | node.lineno, |
| 684 | ) |
| 685 | ) |
| 686 | |
| 687 | if maybe_setup and is_setup_cell(maybe_setup): |
| 688 | next(body) |
| 689 | setup_result = self.extractor.to_setup_cell(maybe_setup) |
| 690 | violations.extend(setup_result.violations) |
| 691 | return ParseResult( |
| 692 | setup_result.unwrap(), |
| 693 | violations=violations, |
| 694 | ) |
| 695 | return ParseResult(violations=violations) |
| 696 | |
| 697 | def parse_body(self, body: PeekStack[Node]) -> ParseResult[list[CellDef]]: |
| 698 | # Continue with remainder of body |