From 4cc6400a2f07d00d01d361acf379678b81c47538 Mon Sep 17 00:00:00 2001 From: bn Date: Thu, 10 Feb 2022 14:03:39 +0000 Subject: [PATCH 1/3] Fix for compat for ipywidgets and ipynb --- jupyter_sphinx/ast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyter_sphinx/ast.py b/jupyter_sphinx/ast.py index 96c3dac..cd6a13f 100644 --- a/jupyter_sphinx/ast.py +++ b/jupyter_sphinx/ast.py @@ -606,7 +606,7 @@ def run(self): def get_widgets(notebook): try: return notebook.metadata.widgets[WIDGET_STATE_MIMETYPE] - except AttributeError: + except (AttributeError, KeyError): # Don't catch KeyError because it's a bug if 'widgets' does # not contain 'WIDGET_STATE_MIMETYPE' return None From 0e2e8f017e83e31c5198a1034429ff95a9659293 Mon Sep 17 00:00:00 2001 From: bn Date: Thu, 10 Feb 2022 14:16:55 +0000 Subject: [PATCH 2/3] removed contradictory comment --- jupyter_sphinx/ast.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/jupyter_sphinx/ast.py b/jupyter_sphinx/ast.py index cd6a13f..7b27fa7 100644 --- a/jupyter_sphinx/ast.py +++ b/jupyter_sphinx/ast.py @@ -607,8 +607,6 @@ def get_widgets(notebook): try: return notebook.metadata.widgets[WIDGET_STATE_MIMETYPE] except (AttributeError, KeyError): - # Don't catch KeyError because it's a bug if 'widgets' does - # not contain 'WIDGET_STATE_MIMETYPE' return None From e4637851343906cc8c299ae709ef0491d7235332 Mon Sep 17 00:00:00 2001 From: bn Date: Fri, 11 Feb 2022 17:13:48 +0000 Subject: [PATCH 3/3] addding message as there issues in the notebooks --- jupyter_sphinx/ast.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jupyter_sphinx/ast.py b/jupyter_sphinx/ast.py index 7b27fa7..a9cbc53 100644 --- a/jupyter_sphinx/ast.py +++ b/jupyter_sphinx/ast.py @@ -606,7 +606,13 @@ def run(self): def get_widgets(notebook): try: return notebook.metadata.widgets[WIDGET_STATE_MIMETYPE] - except (AttributeError, KeyError): + 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: return None