MCPcopy
hub / github.com/marimo-team/marimo / parse_setup

Method parse_setup

marimo/_ast/parse.py:669–695  ·  view source on GitHub ↗
(self, body: PeekStack[Node])

Source from the content-addressed store, hash-verified

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

Callers 2

parse_notebookFunction · 0.95

Calls 8

ViolationClass · 0.90
is_cellFunction · 0.85
is_setup_cellFunction · 0.85
peekMethod · 0.80
to_setup_cellMethod · 0.80
unwrapMethod · 0.80
ParseResultClass · 0.70
appendMethod · 0.45

Tested by 1