diff --git a/IPython/core/display.py b/IPython/core/display.py index ff9f405..36658f4 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -17,16 +17,38 @@ from pathlib import Path, PurePath from IPython.utils.py3compat import cast_unicode from IPython.testing.skipdoctest import skip_doctest -from .display_functions import display, clear_output, publish_display_data, update_display, DisplayHandle +from . import display_functions -__all__ = ['display', 'display_pretty', 'display_html', 'display_markdown', + +__all__ = ['display_pretty', 'display_html', 'display_markdown', 'display_svg', 'display_png', 'display_jpeg', 'display_latex', 'display_json', 'display_javascript', 'display_pdf', 'DisplayObject', 'TextDisplayObject', 'Pretty', 'HTML', 'Markdown', 'Math', 'Latex', 'SVG', 'ProgressBar', 'JSON', - 'GeoJSON', 'Javascript', 'Image', 'clear_output', 'set_matplotlib_formats', - 'set_matplotlib_close', 'publish_display_data', 'update_display', 'DisplayHandle', + 'GeoJSON', 'Javascript', 'Image', 'set_matplotlib_formats', + 'set_matplotlib_close', 'Video'] +_deprecated_names = ["display", "clear_output", "publish_display_data", "update_display", "DisplayHandle"] + +__all__ = __all__ + _deprecated_names + + +# ----- warn to import from IPython.display ----- + +from warnings import warn + + +def __getattr__(name): + if name in _deprecated_names: + warn(f"Importing {name} from IPython.core.display is deprecated since IPython 7.14, please import from IPython display", DeprecationWarning, stacklevel=2) + return getattr(display_functions, name) + + if name in globals().keys(): + return globals()[name] + else: + raise AttributeError(f"module {__name__} has no attribute {name}") + + #----------------------------------------------------------------------------- # utility functions #----------------------------------------------------------------------------- diff --git a/IPython/core/displaypub.py b/IPython/core/displaypub.py index 1da0458..14719a2 100644 --- a/IPython/core/displaypub.py +++ b/IPython/core/displaypub.py @@ -22,7 +22,7 @@ from traitlets.config.configurable import Configurable from traitlets import List # This used to be defined here - it is imported for backwards compatibility -from .display import publish_display_data +from .display_functions import publish_display_data #----------------------------------------------------------------------------- # Main payload class diff --git a/IPython/core/magics/display.py b/IPython/core/magics/display.py index 0785394..d159f89 100644 --- a/IPython/core/magics/display.py +++ b/IPython/core/magics/display.py @@ -12,7 +12,7 @@ #----------------------------------------------------------------------------- # Our own packages -from IPython.core.display import display, Javascript, Latex, SVG, HTML, Markdown +from IPython.display import display, Javascript, Latex, SVG, HTML, Markdown from IPython.core.magic import ( Magics, magics_class, cell_magic ) diff --git a/IPython/core/page.py b/IPython/core/page.py index ed16b61..8a8f14f 100644 --- a/IPython/core/page.py +++ b/IPython/core/page.py @@ -24,7 +24,7 @@ import subprocess from io import UnsupportedOperation from IPython import get_ipython -from IPython.core.display import display +from IPython.display import display from IPython.core.error import TryNext from IPython.utils.data import chop from IPython.utils.process import system diff --git a/IPython/core/pylabtools.py b/IPython/core/pylabtools.py index cb1ce81..ef1539a 100644 --- a/IPython/core/pylabtools.py +++ b/IPython/core/pylabtools.py @@ -354,7 +354,7 @@ def import_pylab(user_ns, import_all=True): # IPython symbols to add user_ns['figsize'] = figsize - from IPython.core.display import display + from IPython.display import display # Add display and getfigs to the user's namespace user_ns['display'] = display user_ns['getfigs'] = getfigs diff --git a/IPython/core/tests/test_display.py b/IPython/core/tests/test_display.py index 0ce4ad2..46a9bbb 100644 --- a/IPython/core/tests/test_display.py +++ b/IPython/core/tests/test_display.py @@ -9,7 +9,7 @@ from unittest import mock import nose.tools as nt -from IPython.core import display +from IPython import display from IPython.core.getipython import get_ipython from IPython.utils.io import capture_output from IPython.utils.tempdir import NamedFileInTemporaryDirectory diff --git a/IPython/display.py b/IPython/display.py index 7d248ba..b7f64f2 100644 --- a/IPython/display.py +++ b/IPython/display.py @@ -1,16 +1,44 @@ """Public API for display tools in IPython. """ -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- # Copyright (C) 2012 The IPython Development Team # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- # Imports -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- -from IPython.core.display import * +from IPython.core.display_functions import * +from IPython.core.display import ( + display_pretty, + display_html, + display_markdown, + display_svg, + display_png, + display_jpeg, + display_latex, + display_json, + display_javascript, + display_pdf, + DisplayObject, + TextDisplayObject, + Pretty, + HTML, + Markdown, + Math, + Latex, + SVG, + ProgressBar, + JSON, + GeoJSON, + Javascript, + Image, + set_matplotlib_formats, + set_matplotlib_close, + Video, +) from IPython.lib.display import * diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index a713071..9bdaefd 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -57,6 +57,7 @@ warnings.filterwarnings('error', message='.*onlyif_any_cmd_exists.*', category=D warnings.filterwarnings('error', message='.*disable_gui.*', category=DeprecationWarning, module='.*') warnings.filterwarnings('error', message='.*ExceptionColors global is deprecated.*', category=DeprecationWarning, module='.*') +warnings.filterwarnings('error', message='.*IPython.core.display.*', category=DeprecationWarning, module='.*') # Jedi older versions warnings.filterwarnings(