https://jupyter-client.readthedocs.io/en/stable/messaging.html#execution-results
Last active
December 16, 2024 16:19
-
-
Save flying-sheep/a057ebf61f9082d524f6f678fbb18fdc to your computer and use it in GitHub Desktop.
Jupyter reply types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MT = TypeVar("MT", bound=LiteralString) | |
C = TypeVar("C", bound="_ContentOkBase") | |
class _ReplyBase(TypedDict, Generic[MT, C]): | |
"""Jupyter reply message.""" | |
header: ReplyHeader[MT] | |
content: C | ContentError | ContentAbort | |
class ReplyHeader(TypedDict, Generic[MT]): | |
"""Jupyter reply message header.""" | |
msg_type: MT | |
class _ContentOkBase(TypedDict): | |
"""Jupyter successful message reply content.""" | |
status: Literal["ok"] | |
class ContentAbort(TypedDict): | |
"""Jupyter abort message reply content.""" | |
status: Literal["abort"] | |
class ContentError(TypedDict): | |
"""Jupyter error message reply content.""" | |
status: Literal["error"] | |
ename: str | |
evalue: str | |
traceback: list[str] | |
class ExecuteReplyContent(_ContentOkBase): | |
execution_count: int | |
ExecuteReply = _ReplyBase[Literal["execute_result"], ExecuteReplyContent] | |
class StreamContent(_ContentOkBase): | |
name: Literal["stdout", "stderr"] | |
text: str | |
class DisplayDataContent(_ContentOkBase): | |
data: dict[str, str] | |
metadata: dict[str, str] | |
class ExecuteResultContent(DisplayDataContent): | |
execution_count: int | |
Stream = _ReplyBase[Literal["stream"], StreamContent] | |
DisplayData = _ReplyBase[Literal["display_data"], DisplayDataContent] | |
ExecuteResult = _ReplyBase[Literal["execute_result"], ExecuteResultContent] | |
IoPubMsg = Stream | DisplayData | ExecuteResult |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment