From e84602b8f2b95d10d45eb11369ae7d627339c881 Mon Sep 17 00:00:00 2001 From: robot-piglet Date: Tue, 12 Mar 2024 17:24:47 +0300 Subject: Intermediate changes --- .../python/ipython/py3/IPython/core/displaypub.py | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'contrib/python/ipython/py3/IPython/core/displaypub.py') diff --git a/contrib/python/ipython/py3/IPython/core/displaypub.py b/contrib/python/ipython/py3/IPython/core/displaypub.py index 74028ec79e0..ed6a7082e75 100644 --- a/contrib/python/ipython/py3/IPython/core/displaypub.py +++ b/contrib/python/ipython/py3/IPython/core/displaypub.py @@ -24,7 +24,9 @@ from traitlets import List # This used to be defined here - it is imported for backwards compatibility from .display_functions import publish_display_data -#----------------------------------------------------------------------------- +import typing as t + +# ----------------------------------------------------------------------------- # Main payload class #----------------------------------------------------------------------------- @@ -103,9 +105,9 @@ class DisplayPublisher(Configurable): rather than creating a new output. """ - handlers = {} + handlers: t.Dict = {} if self.shell is not None: - handlers = getattr(self.shell, 'mime_renderers', {}) + handlers = getattr(self.shell, "mime_renderers", {}) for mime, handler in handlers.items(): if mime in data: @@ -125,11 +127,20 @@ class DisplayPublisher(Configurable): class CapturingDisplayPublisher(DisplayPublisher): """A DisplayPublisher that stores""" - outputs = List() - def publish(self, data, metadata=None, source=None, *, transient=None, update=False): - self.outputs.append({'data':data, 'metadata':metadata, - 'transient':transient, 'update':update}) + outputs: List = List() + + def publish( + self, data, metadata=None, source=None, *, transient=None, update=False + ): + self.outputs.append( + { + "data": data, + "metadata": metadata, + "transient": transient, + "update": update, + } + ) def clear_output(self, wait=False): super(CapturingDisplayPublisher, self).clear_output(wait) -- cgit v1.3