Repository: ipython/ipython

Issue:
Deprecate and cleaned publish_display_data's and DisplayPublisher/publish "source" parameter
It's been unused and deprecated for years.

1) It should emit a warning when parameter is passed in. 
2) the deprecation should say since when it's deprecated. 

Once this is done, we can think of removing it in a couple of years. 






Discussion:
I would like to work this issue.


Resolving patch:
diff --git a/IPython/core/display_functions.py b/IPython/core/display_functions.py
--- a/IPython/core/display_functions.py
+++ b/IPython/core/display_functions.py
@@ -8,6 +8,7 @@
 from binascii import b2a_hex
 import os
 import sys
+import warnings
 
 __all__ = ['display', 'clear_output', 'publish_display_data', 'update_display', 'DisplayHandle']
 
@@ -33,9 +34,17 @@ def _merge(d1, d2):
 # Main functions
 #-----------------------------------------------------------------------------
 
+class _Sentinel:
+    def __repr__(self):
+        return "<deprecated>"
+
+
+_sentinel = _Sentinel()
 
 # use * to indicate transient is keyword-only
-def publish_display_data(data, metadata=None, source=None, *, transient=None, **kwargs):
+def publish_display_data(
+    data, metadata=None, source=_sentinel, *, transient=None, **kwargs
+):
     """Publish data and metadata to all frontends.
 
     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, **
     """
     from IPython.core.interactiveshell import InteractiveShell
 
+    if source is not _sentinel:
+        warnings.warn(
+            "The `source` parameter emit a  deprecation warning since"
+            " IPython 8.0, it had no effects for a long time and will "
+            " be removed in future versions.",
+            DeprecationWarning,
+            stacklevel=2,
+        )
     display_pub = InteractiveShell.instance().display_pub
 
     # only pass transient if supplied,


Test patch:
diff --git a/IPython/terminal/tests/test_interactivshell.py b/IPython/terminal/tests/test_interactivshell.py
--- a/IPython/terminal/tests/test_interactivshell.py
+++ b/IPython/terminal/tests/test_interactivshell.py
@@ -191,26 +191,29 @@ def _repr_html_(self):
         class Test2(Test):
             def _ipython_display_(self):
                 from IPython.display import display, HTML
-                display(HTML('<custom>'))
+
+                display(HTML("<custom>"))
 
         # verify that mimehandlers are called
         called = False
 
         def handler(data, metadata):
-            print('Handler called')
+            print("Handler called")
             nonlocal called
             called = True
 
         ip.display_formatter.active_types.append("text/html")
         ip.display_formatter.formatters["text/html"].enabled = True
         ip.mime_renderers["text/html"] = handler
-
-
-        obj = Test()
-        display(obj)
+        try:
+            obj = Test()
+            display(obj)
+        finally:
+            ip.display_formatter.formatters["text/html"].enabled = False
+            del ip.mime_renderers["text/html"]
 
         assert called == True
-        
+
 
 def syntax_error_transformer(lines):
     """Transformer that throws SyntaxError if 'syntaxerror' is in the code."""