Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Jan 8, 2025
1 parent 46c6814 commit f8e74ff
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
run: |
micromamba install pip nodejs=18
pip install ".[test]"
pip install "pycrdt >=0.12.1"
- name: Build JavaScript assets
working-directory: javascript
run: |
Expand Down
8 changes: 4 additions & 4 deletions jupyter_ydoc/ybasedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class YBaseDoc(ABC):

_ydoc: YDoc
_ystate: YState
_subscriptions: Dict[Any, Subscription]
_subscriptions: dict[Any, Subscription]
_undo_manager: UndoManager

def __init__(self, ydoc: YDoc | Doc | None = None, awareness: Awareness | None = None):
Expand Down Expand Up @@ -121,7 +121,7 @@ def dirty(self) -> bool | None:
"""
try:
return self._ystate.dirty
except:
except AttributeError:
return None

@dirty.setter
Expand All @@ -144,7 +144,7 @@ def hash(self) -> str | None:
"""
try:
return self._ystate.hash
except:
except AttributeError:
return None

@hash.setter
Expand All @@ -167,7 +167,7 @@ def path(self) -> str | None:
"""
try:
return self._ystate.path
except:
except AttributeError:
return None

@path.setter
Expand Down
2 changes: 1 addition & 1 deletion jupyter_ydoc/yblob.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get(self) -> bytes:
"""
try:
return self._ysource.bytes
except:
except AttributeError:
return b""

def set(self, value: bytes) -> None:
Expand Down
18 changes: 10 additions & 8 deletions jupyter_ydoc/ynotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def cell_number(self) -> int:
"""
return len(self._ycells)

def get_cell(self, index: int) -> Dict[str, Any]:
def get_cell(self, index: int) -> dict[str, Any]:
"""
Returns a cell.
Expand All @@ -166,7 +166,7 @@ def get_cell(self, index: int) -> Dict[str, Any]:
del cell["attachments"]
return cell

def append_cell(self, value: Dict[str, Any]) -> None:
def append_cell(self, value: dict[str, Any]) -> None:
"""
Appends a cell.
Expand All @@ -176,7 +176,7 @@ def append_cell(self, value: Dict[str, Any]) -> None:
ycell = self.create_ycell(value)
self._ycells.append(ycell)

def set_cell(self, index: int, value: Dict[str, Any]) -> None:
def set_cell(self, index: int, value: dict[str, Any]) -> None:
"""
Sets a cell into indicated position.
Expand All @@ -189,7 +189,7 @@ def set_cell(self, index: int, value: Dict[str, Any]) -> None:
ycell = self.create_ycell(value)
self.set_ycell(index, ycell)

def create_ycell(self, value: Dict[str, Any]) -> YCell:
def create_ycell(self, value: dict[str, Any]) -> YCell:
"""
Creates YCell with the content of the cell.
Expand Down Expand Up @@ -239,7 +239,7 @@ def set_ycell(self, index: int, ycell: YCell) -> None:
"""
self._ycells[index] = ycell

def get(self) -> Dict:
def get(self) -> dict:
"""
Returns the content of the document.
Expand Down Expand Up @@ -269,7 +269,7 @@ def get(self) -> Dict:
nbformat_minor=int(meta.get("nbformat_minor", 0)),
)

def set(self, value: Dict) -> None:
def set(self, value: dict) -> None:
"""
Sets the content of the document.
Expand Down Expand Up @@ -306,9 +306,11 @@ def set(self, value: Dict) -> None:
ymetadata = YMetadata()
self._ymeta.metadata = ymetadata
metadata = nb.get("metadata", {})
# ymetadata.language_info = asdict(LanguageInfo(**metadata.get("language_info", {"name": ""})))
# ymetadata.language_info =
# asdict(LanguageInfo(**metadata.get("language_info", {"name": ""})))
ymetadata.language_info = metadata.get("language_info", {"name": ""})
# ymetadata.kernelspec = asdict(Kernelspec(**metadata.get("kernelspec", {"name": "", "display_name": ""})))
# ymetadata.kernelspec =
# asdict(Kernelspec(**metadata.get("kernelspec", {"name": "", "display_name": ""})))
ymetadata.kernelspec = metadata.get("kernelspec", {"name": "", "display_name": ""})

def observe(self, callback: Callable[[str, Any], None]) -> None:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ requires-python = ">=3.8"
keywords = ["jupyter", "pycrdt", "yjs"]
dependencies = [
"importlib_metadata >=3.6; python_version<'3.10'",
"pycrdt >=0.12.1,<0.13.0",
# "pycrdt >=0.12.1,<0.13.0",
"pycrdt >=0.10.1,<0.11.0",
]

[[project.authors]]
Expand Down

0 comments on commit f8e74ff

Please sign in to comment.