diff options
| author | Alexander Smirnov <[email protected]> | 2024-03-13 10:33:47 +0000 |
|---|---|---|
| committer | Alexander Smirnov <[email protected]> | 2024-03-13 10:33:47 +0000 |
| commit | 1df54be5538361db7f33afc618d1597272414294 (patch) | |
| tree | bb39e4b75db0b0a9722468eacef91ffd1388eb8d /contrib/python/ipython/py3/IPython/core/displaypub.py | |
| parent | 7a673cf01feefbe95bf5e7396d9179a5f283aeba (diff) | |
| parent | 01aef806626b16e9817e07f718f10e151f52e400 (diff) | |
Merge branch 'rightlib' into mergelibs-240313-1032
Diffstat (limited to 'contrib/python/ipython/py3/IPython/core/displaypub.py')
| -rw-r--r-- | contrib/python/ipython/py3/IPython/core/displaypub.py | 25 |
1 files changed, 18 insertions, 7 deletions
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) |
