Skip to content

Commit 9477c5c

Browse files
committed
add-traitlet-for-storing-display-ouputs
1 parent f9b9db8 commit 9477c5c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ipykernel/zmqshell.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from IPython.utils.process import arg_split, system # type:ignore[attr-defined]
3636
from jupyter_client.session import Session, extract_header
3737
from jupyter_core.paths import jupyter_runtime_dir
38-
from traitlets import Any, CBool, CBytes, Instance, Type, default, observe
38+
from traitlets import Any, Bool, CBool, CBytes, Instance, Type, default, observe
3939

4040
from ipykernel import connect_qtconsole, get_connection_file, get_connection_info
4141
from ipykernel.displayhook import ZMQShellDisplayHook
@@ -59,6 +59,11 @@ class ZMQDisplayPublisher(DisplayPublisher):
5959
_parent_header: contextvars.ContextVar[dict[str, Any]]
6060
topic = CBytes(b"display_data")
6161

62+
store_display_history = Bool(
63+
False,
64+
help="If set to True, store display outputs in the history manager. Default is False.",
65+
).tag(config=True)
66+
6267
# thread_local:
6368
# An attribute used to ensure the correct output message
6469
# is processed. See ipykernel Issue 113 for a discussion.
@@ -121,7 +126,8 @@ def publish( # type:ignore[override]
121126
If True, send an update_display_data message instead of display_data.
122127
"""
123128
if (
124-
self.shell is not None
129+
self.store_display_history
130+
and self.shell is not None
125131
and hasattr(self.shell, "history_manager")
126132
and HistoryOutput is not None
127133
):

0 commit comments

Comments
 (0)