##// END OF EJS Templates
Mark source parameter of publish_display_data....
Matthias Bussonnier -
Show More
@@ -8,6 +8,7
8 from binascii import b2a_hex
8 from binascii import b2a_hex
9 import os
9 import os
10 import sys
10 import sys
11 import warnings
11
12
12 __all__ = ['display', 'clear_output', 'publish_display_data', 'update_display', 'DisplayHandle']
13 __all__ = ['display', 'clear_output', 'publish_display_data', 'update_display', 'DisplayHandle']
13
14
@@ -33,9 +34,17 def _merge(d1, d2):
33 # Main functions
34 # Main functions
34 #-----------------------------------------------------------------------------
35 #-----------------------------------------------------------------------------
35
36
37 class _Sentinel:
38 def __repr__(self):
39 return "<deprecated>"
40
41
42 _sentinel = _Sentinel()
36
43
37 # use * to indicate transient is keyword-only
44 # use * to indicate transient is keyword-only
38 def publish_display_data(data, metadata=None, source=None, *, transient=None, **kwargs):
45 def publish_display_data(
46 data, metadata=None, source=_sentinel, *, transient=None, **kwargs
47 ):
39 """Publish data and metadata to all frontends.
48 """Publish data and metadata to all frontends.
40
49
41 See the ``display_data`` message in the messaging documentation for
50 See the ``display_data`` message in the messaging documentation for
@@ -65,6 +74,14 def publish_display_data(data, metadata=None, source=None, *, transient=None, **
65 """
74 """
66 from IPython.core.interactiveshell import InteractiveShell
75 from IPython.core.interactiveshell import InteractiveShell
67
76
77 if source is not _sentinel:
78 warnings.warn(
79 "The `source` parameter emit a deprecation warning since"
80 " IPython 8.0, it had no effects for a long time and will "
81 " be removed in future versions.",
82 DeprecationWarning,
83 stacklevel=2,
84 )
68 display_pub = InteractiveShell.instance().display_pub
85 display_pub = InteractiveShell.instance().display_pub
69
86
70 # only pass transient if supplied,
87 # only pass transient if supplied,
@@ -191,13 +191,14 class InteractiveShellTestCase(unittest.TestCase):
191 class Test2(Test):
191 class Test2(Test):
192 def _ipython_display_(self):
192 def _ipython_display_(self):
193 from IPython.display import display, HTML
193 from IPython.display import display, HTML
194 display(HTML('<custom>'))
194
195 display(HTML("<custom>"))
195
196
196 # verify that mimehandlers are called
197 # verify that mimehandlers are called
197 called = False
198 called = False
198
199
199 def handler(data, metadata):
200 def handler(data, metadata):
200 print('Handler called')
201 print("Handler called")
201 nonlocal called
202 nonlocal called
202 called = True
203 called = True
203
204
@@ -205,12 +206,11 class InteractiveShellTestCase(unittest.TestCase):
205 ip.display_formatter.formatters["text/html"].enabled = True
206 ip.display_formatter.formatters["text/html"].enabled = True
206 ip.mime_renderers["text/html"] = handler
207 ip.mime_renderers["text/html"] = handler
207
208
208
209 obj = Test()
209 obj = Test()
210 display(obj)
210 display(obj)
211
211
212 assert called == True
212 assert called == True
213
213
214
214
215 def syntax_error_transformer(lines):
215 def syntax_error_transformer(lines):
216 """Transformer that throws SyntaxError if 'syntaxerror' is in the code."""
216 """Transformer that throws SyntaxError if 'syntaxerror' is in the code."""
General Comments 0
You need to be logged in to leave comments. Login now