Skip to content

Commit 106ee07

Browse files
Merge pull request #43 from jimgoo/main
Handle missing attachment key
2 parents a5e6c3c + 05d3a05 commit 106ee07

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

jupyter_ydoc/ydoc.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ def get_cell(self, index: int) -> Dict[str, Any]:
9090
if "id" in cell and meta["nbformat"] == 4 and meta["nbformat_minor"] <= 4:
9191
# strip cell IDs if we have notebook format 4.0-4.4
9292
del cell["id"]
93-
if cell["cell_type"] in ["raw", "markdown"] and not cell["attachments"]:
93+
if (
94+
"attachments" in cell
95+
and cell["cell_type"] in ["raw", "markdown"]
96+
and not cell["attachments"]
97+
):
9498
del cell["attachments"]
9599
return cell
96100

@@ -137,7 +141,11 @@ def get(self):
137141
if "id" in cell and meta["nbformat"] == 4 and meta["nbformat_minor"] <= 4:
138142
# strip cell IDs if we have notebook format 4.0-4.4
139143
del cell["id"]
140-
if cell["cell_type"] in ["raw", "markdown"] and not cell["attachments"]:
144+
if (
145+
"attachments" in cell
146+
and cell["cell_type"] in ["raw", "markdown"]
147+
and not cell["attachments"]
148+
):
141149
del cell["attachments"]
142150
cells.append(cell)
143151

0 commit comments

Comments
 (0)