From 531489067d61c80720181f0923f0c740e0cd2502 2023-04-28 08:07:35 From: Matthias Bussonnier Date: 2023-04-28 08:07:35 Subject: [PATCH] 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