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

Method _resolve_target

marimo/_code_mode/_context.py:979–1008  ·  view source on GitHub ↗

Resolve a cell ID or name to a `CellId_t`. Checks the live graph first, then pending adds (by ID and by name), then queued renames from `edit_cell`.

(self, target: str)

Source from the content-addressed store, hash-verified

977 # ------------------------------------------------------------------
978
979 def _resolve_target(self, target: str) -> CellId_t:
980 """Resolve a cell ID or name to a `CellId_t`.
981
982 Checks the live graph first, then pending adds (by ID and by
983 name), then queued renames from `edit_cell`.
984 """
985 # Try the live graph.
986 try:
987 return self.cells._resolve(target)
988 except KeyError:
989 pass
990
991 # Try pending adds (by cell ID).
992 cid = CellId_t(target)
993 if cid in self._pending_adds:
994 return cid
995
996 # Try pending adds (by name).
997 for pending_id, add_op in self._pending_adds.items():
998 if add_op.name == target:
999 return pending_id
1000
1001 # Try queued renames from edit_cell ops.
1002 for op in self._ops:
1003 if isinstance(op, _UpdateOp) and op.name == target:
1004 return op.new_cell_id or op.cell_id
1005
1006 raise KeyError(
1007 f"Cell {target!r} not found in notebook or pending adds"
1008 )
1009
1010 def _resolve_new_cell(
1011 self, name: str | None

Callers 5

create_cellMethod · 0.95
edit_cellMethod · 0.95
delete_cellMethod · 0.95
move_cellMethod · 0.95
run_cellMethod · 0.95

Calls 2

_resolveMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected