yera.runtime.handlers.base
Abstract base class for Yera event handlers.
Symbols
BaseHandler
ABCFallbackHandler, ANSIFormEchoHandler, JupyterFormEchoHandler, ANSITreeSelectorHandler, JupyterTreeSelectorHandler, ANSIResultHandler, ANSIImageHandler, JupyterImageHandler, BaseMarkdownHandler, ANSIFormHandler, JupyterFormHandlerAbstract 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. No-op by default.
BaseHandler.__exit__
__exit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) → NoneExit the handler context. No-op by default.
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.