From 1f165adb67a16288f06f1ae50f8b0d804278f129 2023-04-28 08:42:24 From: Matthias Bussonnier Date: 2023-04-28 08:42:24 Subject: [PATCH] Backport PR #14011 on branch 8.12.x (Raise an ImportError if docstrings should be sphinxified, but docrepr is't available) (#14045) Backport PR #14011: Raise an ImportError if docstrings should be sphinxified, but docrepr is't available --- diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index e4a1a4c..7392de7 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -1781,9 +1781,12 @@ class InteractiveShell(SingletonConfigurable): This function is meant to be called by pdef, pdoc & friends. """ info: OInfo = self._object_find(oname, namespaces) - docformat = ( - sphinxify(self.object_inspect(oname)) if self.sphinxify_docstring else None - ) + if self.sphinxify_docstring: + if sphinxify is None: + raise ImportError("Module ``docrepr`` required but missing") + docformat = sphinxify(self.object_inspect(oname)) + else: + docformat = None if info.found or hasattr(info.parent, oinspect.HOOK_NAME): pmethod = getattr(self.inspector, meth) # TODO: only apply format_screen to the plain/text repr of the mime