diff --git a/jupyter_sphinx/ast.py b/jupyter_sphinx/ast.py index 96c3dac..a9cbc53 100644 --- a/jupyter_sphinx/ast.py +++ b/jupyter_sphinx/ast.py @@ -606,9 +606,13 @@ def run(self): def get_widgets(notebook): try: return notebook.metadata.widgets[WIDGET_STATE_MIMETYPE] + except KeyError: + from . import logger + logger.warning( + 'Unable to get widget state in current notebook - are you sure that pywidgets rendered correctly in all your notebooks ?' + ) + return None except AttributeError: - # Don't catch KeyError because it's a bug if 'widgets' does - # not contain 'WIDGET_STATE_MIMETYPE' return None