From d800d89c63142382908571ef77255e4f02468972 Mon Sep 17 00:00:00 2001 From: Min RK Date: Sat, 9 Jul 2022 17:19:42 -0700 Subject: [PATCH] Fix notebook shim version check Use parsed notebook.version_info, not private notebook._version with string comparison --- nbclassic/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nbclassic/__init__.py b/nbclassic/__init__.py index 52ab80423..7676bff4c 100644 --- a/nbclassic/__init__.py +++ b/nbclassic/__init__.py @@ -1,6 +1,6 @@ import os import sys -from ._version import __version__ +from ._version import __version__ # Packagers: modify this line if you store the notebook static files elsewhere @@ -10,8 +10,9 @@ # Notebook shim to ensure notebook extensions backwards compatiblity. try: - from notebook._version import __version__ as notebook_version -except Exception as e: + from notebook import version_info as notebook_version_info +except Exception: + notebook_version_info = None # No notebook python package found. # Shimming notebook to jupyter_server for notebook extensions backwards compatibility. # We shim the complete notebook module. @@ -22,10 +23,10 @@ handlers.IPythonHandler = handlers.JupyterHandler notebook_handlers.IPythonHandler = handlers.JupyterHandler -if "notebook_version" in locals(): +if notebook_version_info is not None: # Notebook is available on the platform. # We shim based on the notebook version. - if not notebook_version < "7": + if notebook_version_info >= (7,): from .shim_notebook import shim_notebook # Shimming existing notebook python package > 6 to jupyter_server. # For notebook extensions backwards compatibility.