From 3d8e5680393cf88c553c19fb8be0fdde417c5f8c Mon Sep 17 00:00:00 2001
From: David Brochart <david.brochart@gmail.com>
Date: Thu, 17 Oct 2024 09:59:07 +0200
Subject: [PATCH] Revert #266

---
 jupyter_ydoc/ynotebook.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/jupyter_ydoc/ynotebook.py b/jupyter_ydoc/ynotebook.py
index 60e5dc3..4a9f4d5 100644
--- a/jupyter_ydoc/ynotebook.py
+++ b/jupyter_ydoc/ynotebook.py
@@ -225,7 +225,17 @@ def set(self, value: Dict) -> None:
         nb_without_cells = {key: value[key] for key in value.keys() if key != "cells"}
         nb = copy.deepcopy(nb_without_cells)
         cast_all(nb, int, float)  # Yjs expects numbers to be floating numbers
-        cells = value["cells"]
+        cells = value["cells"] or [
+            {
+                "cell_type": "code",
+                "execution_count": None,
+                # auto-created empty code cell without outputs ought be trusted
+                "metadata": {"trusted": True},
+                "outputs": [],
+                "source": "",
+                "id": str(uuid4()),
+            }
+        ]
 
         with self._ydoc.transaction():
             # clear document