From 60e582d02612437e4c4c07383f218049c781ad67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Wed, 15 Jan 2025 12:11:09 +0100 Subject: [PATCH 1/2] Fix missing nbformat version --- jupyter_ydoc/ynotebook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyter_ydoc/ynotebook.py b/jupyter_ydoc/ynotebook.py index 864a79f..02b085e 100644 --- a/jupyter_ydoc/ynotebook.py +++ b/jupyter_ydoc/ynotebook.py @@ -202,7 +202,7 @@ def get(self) -> Dict: cells = [] for i in range(len(self._ycells)): cell = self.get_cell(i) - if "id" in cell and meta["nbformat"] == 4 and meta["nbformat_minor"] <= 4: + if "id" in cell and meta.get("nbformat", 0) == 4 and meta.get("nbformat_minor", 0) <= 4: # strip cell IDs if we have notebook format 4.0-4.4 del cell["id"] if ( From c1abee4327f7103bdb980861fa839377ffdb6785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Wed, 15 Jan 2025 12:14:43 +0100 Subject: [PATCH 2/2] Convert format version to int --- jupyter_ydoc/ynotebook.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jupyter_ydoc/ynotebook.py b/jupyter_ydoc/ynotebook.py index 02b085e..523b147 100644 --- a/jupyter_ydoc/ynotebook.py +++ b/jupyter_ydoc/ynotebook.py @@ -202,7 +202,11 @@ def get(self) -> Dict: cells = [] for i in range(len(self._ycells)): cell = self.get_cell(i) - if "id" in cell and meta.get("nbformat", 0) == 4 and meta.get("nbformat_minor", 0) <= 4: + if ( + "id" in cell + and int(meta.get("nbformat", 0)) == 4 + and int(meta.get("nbformat_minor", 0)) <= 4 + ): # strip cell IDs if we have notebook format 4.0-4.4 del cell["id"] if (