Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ from jupyter_ydoc import YFile, YNotebook
The `"jupyter_ydoc"` entry point group can be populated with your own documents, e.g. by adding the
following to your package's `setup.cfg`:

```
```ini
[options.entry_points]
jupyter_ydoc =
my_document = my_package.my_file:MyDocumentClass
Expand Down
3 changes: 3 additions & 0 deletions jupyter_ydoc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

import sys

from ._version import __version__ # noqa
Expand Down
3 changes: 3 additions & 0 deletions jupyter_ydoc/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

from typing import Dict, List, Type, Union

INT = Type[int]
Expand Down
10 changes: 7 additions & 3 deletions jupyter_ydoc/ydoc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

import copy
import json
from typing import Any, Dict
from uuid import uuid4

Expand Down Expand Up @@ -93,8 +97,8 @@ def __init__(self, *args, **kwargs):
self._ycells = self._ydoc.get_array("cells")

def get_cell(self, index: int) -> Dict[str, Any]:
meta = self._ymeta.to_json()
cell = self._ycells[index].to_json()
meta = json.loads(self._ymeta.to_json())
cell = json.loads(self._ycells[index].to_json())
cast_all(cell, float, int) # cells coming from Yjs have e.g. execution_count as float
if "id" in cell and meta["nbformat"] == 4 and meta["nbformat_minor"] <= 4:
# strip cell IDs if we have notebook format 4.0-4.4
Expand Down Expand Up @@ -145,7 +149,7 @@ def set_ycell(self, index: int, ycell: Y.YMap, txn=None):
self._ycells.insert(txn, index, ycell)

def get(self):
meta = self._ymeta.to_json()
meta = json.loads(self._ymeta.to_json())
cast_all(meta, float, int) # notebook coming from Yjs has e.g. nbformat as float
cells = []
for i in range(len(self._ycells)):
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ requires-python = ">=3.7"
keywords = ["jupyter", "ypy"]
dependencies = [
"importlib_metadata >=3.6; python_version<\"3.10\"",
"y-py >=0.5.3,<0.6.0",
"y-py >=0.6.0,<0.7.0",
]

[[project.authors]]
Expand All @@ -23,7 +23,7 @@ test = [
"pytest",
"pytest-asyncio",
"websockets >=10.0",
"ypy-websocket >=0.3.1,<0.4.0",
"ypy-websocket >=0.8.4,<0.9.0",
]
dev = [
"click",
Expand Down