Skip to content

Commit 3662d97

Browse files
Move nbformat and nbformat_minor to meta YMap (#21)
* Move nbformat and nbformat_minor to meta YMap * Change nbformatMinor to nbformat_minor * Lint
1 parent 72f1c7b commit 3662d97

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

jupyter_ydoc/ydoc.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,17 @@ def __init__(self, *args, **kwargs):
8383
def source(self):
8484
cells = self._ycells.to_json()
8585
meta = self._ymeta.to_json()
86-
state = self._ystate.to_json()
8786
cast_all(cells, float, int)
8887
cast_all(meta, float, int)
8988
for cell in cells:
90-
if "id" in cell and state["nbformat"] == 4 and state["nbformatMinor"] <= 4:
89+
if "id" in cell and meta["nbformat"] == 4 and meta["nbformat_minor"] <= 4:
9190
# strip cell IDs if we have notebook format 4.0-4.4
9291
del cell["id"]
9392
return dict(
9493
cells=cells,
9594
metadata=meta["metadata"],
96-
nbformat=int(state["nbformat"]),
97-
nbformat_minor=int(state["nbformatMinor"]),
95+
nbformat=int(meta["nbformat"]),
96+
nbformat_minor=int(meta["nbformat_minor"]),
9897
)
9998

10099
@source.setter
@@ -136,8 +135,8 @@ def source(self, value):
136135
if ycells:
137136
self._ycells.extend(t, ycells)
138137
self._ymeta.set(t, "metadata", nb["metadata"])
139-
self._ystate.set(t, "nbformat", nb["nbformat"])
140-
self._ystate.set(t, "nbformatMinor", nb["nbformat_minor"])
138+
self._ymeta.set(t, "nbformat", nb["nbformat"])
139+
self._ymeta.set(t, "nbformat_minor", nb["nbformat_minor"])
141140

142141
def observe(self, callback):
143142
self.unobserve()

0 commit comments

Comments
 (0)