yera.runtime.handlers.base
Define the block-scoped interface shared by runtime event handlers.
The event router constructs a handler for each open block, binds its open parent, enters it before the first event, and exits it after the terminal event.
Symbols
BaseHandler
ABCFallbackHandler, JupyterImageHandler, ANSIImageHandler, JupyterFormHandler, ANSIFormHandler, JupyterTreeSelectorHandler, ANSITreeSelectorHandler, JupyterFormEchoHandler, ANSIFormEchoHandler, BaseChartHandler, ANSIResultHandler, BaseMarkdownHandlerAbstract base for all Yera event handlers.
Each handler is responsible for processing events of a single block type.
Handlers are used as context managers so that stateful implementations
(e.g. a streaming markdown handler managing a live display) can acquire
and release resources around a block. The default __enter__
and __exit__ are
no-ops; override them only when setup or teardown is required.
Methods
BaseHandler.bind_parent
bind_parent(
parent: BaseHandler | None,
) → NoneAttach the handler owning this block's parent, if any.
Called by the router once, before __enter__. None at top level
or when the parent block has already closed.
Parameters
The enclosing block's handler.
BaseHandler.__enter__
__enter__() → SelfEnter the handler context.
Returns
This handler. The default implementation performs no setup.
BaseHandler.__exit__
__exit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) → NoneExit the handler context.
Parameters
Type of exception leaving the context, if any.
Exception leaving the context, if any.
Traceback associated with the exception, if any.
BaseHandler.push
push(
event: OutputEvent,
) → NoneHandle an event.
Called once per event in the block, in order. Stateful handlers accumulate state across repeated calls within a single context manager scope.
Parameters
The output event to handle.