Skip to content

Commit

Permalink
Don't set attachments if there are none
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Oct 13, 2022
1 parent 9091f34 commit 8a8c738
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions jupyter_ydoc/ydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def get_cell(self, index: int) -> Dict[str, Any]:
del cell["id"]
if (
"attachments" in cell
and cell["cell_type"] in ["raw", "markdown"]
and cell["cell_type"] in ("raw", "markdown")
and not cell["attachments"]
):
del cell["attachments"]
Expand All @@ -123,7 +123,8 @@ def create_ycell(self, value: Dict[str, Any]) -> None:
cell["metadata"] = Y.YMap(cell.get("metadata", {}))

if cell_type in ("raw", "markdown"):
cell["attachments"] = cell.get("attachments", {})
if "attachments" in cell and not cell["attachments"]:
del cell["attachments"]
elif cell_type == "code":
cell["outputs"] = Y.YArray(cell.get("outputs", []))

Expand Down

0 comments on commit 8a8c738

Please sign in to comment.