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

Class PeekStack

marimo/_ast/parse.py:735–761  ·  view source on GitHub ↗

Builtins don't have a peek, which is useful here.

Source from the content-addressed store, hash-verified

733
734
735class PeekStack(Generic[U]):
736 """Builtins don't have a peek, which is useful here."""
737
738 def __init__(self, iterable: Iterator[U]):
739 self._iterable = iterable
740 self._next: U | None = None
741 self.last: U | None = None
742
743 def __next__(self) -> U | None:
744 if self._next:
745 self.last = self._next
746 self._next = None
747 else:
748 try:
749 self.last = next(self._iterable)
750 except StopIteration:
751 self.last = None
752 return self.last
753
754 def peek(self) -> U | None:
755 if self._next:
756 return self._next
757 try:
758 self._next = next(self._iterable)
759 except StopIteration:
760 self._next = None
761 return self._next
762
763
764def _maybe_kwargs(

Callers 2

node_stackMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…