diff --git a/plugins/yjs/fps_yjs/ywidgets/widgets.py b/plugins/yjs/fps_yjs/ywidgets/widgets.py index 52eeae03..d5d7f4c2 100644 --- a/plugins/yjs/fps_yjs/ywidgets/widgets.py +++ b/plugins/yjs/fps_yjs/ywidgets/widgets.py @@ -1,15 +1,15 @@ import sys from typing import Any -from pycrdt import TransactionEvent - try: - from ypywidgets.utils import ( # type: ignore + import ypywidgets # noqa: F401 + from pycrdt import ( + TransactionEvent, YMessageType, YSyncMessageType, + create_sync_message, create_update_message, - process_sync_message, - sync, + handle_sync_message, ) ypywidgets_installed = True except ImportError: @@ -41,15 +41,15 @@ def comm_open(self, msg, comm) -> None: self.comm = comm model = self.ydocs[f"{name}Model"]() self.widgets[comm_id] = {"model": model, "comm": comm} - msg = sync(model.ydoc) - comm.send(**msg) + msg = create_sync_message(model.ydoc) + comm.send(buffers=[msg]) def comm_msg(self, msg) -> None: comm_id = msg["content"]["comm_id"] message = bytes(msg["buffers"][0]) if message[0] == YMessageType.SYNC: ydoc = self.widgets[comm_id]["model"].ydoc - reply = process_sync_message( + reply = handle_sync_message( message[1:], ydoc, ) diff --git a/pyproject.toml b/pyproject.toml index 15643c82..297a424d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ test = [ "requests", "websockets", "ipykernel", - "ypywidgets >=0.9.1,<0.10.0", + "ypywidgets >=0.9.3,<0.10.0", "ypywidgets-textual >=0.5.0,<0.6.0", ] docs = [ "mkdocs", "mkdocs-material" ] diff --git a/tests/test_execute.py b/tests/test_execute.py index e45e700c..d423f1a1 100644 --- a/tests/test_execute.py +++ b/tests/test_execute.py @@ -55,7 +55,6 @@ async def recv(self) -> bytes: return bytes(b) -@pytest.mark.skip(reason="FIXME: caused by new ypywidgets version") @pytest.mark.asyncio @pytest.mark.parametrize("auth_mode", ("noauth",)) async def test_execute(auth_mode, unused_tcp_port): diff --git a/tests/test_server.py b/tests/test_server.py index 0ba0cc03..66a986d4 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -106,8 +106,8 @@ async def test_rest_api(start_jupyverse): cells = json.loads(str(ycells)) assert cells[0]["outputs"] == [ { - "data": {"text/plain": ["3"]}, - "execution_count": 1.0, + "data": {"text/plain": "3"}, + "execution_count": 1, "metadata": {}, "output_type": "execute_result", } @@ -117,8 +117,8 @@ async def test_rest_api(start_jupyverse): ] assert cells[2]["outputs"] == [ { - "data": {"text/plain": ["7"]}, - "execution_count": 3.0, + "data": {"text/plain": "7"}, + "execution_count": 3, "metadata": {}, "output_type": "execute_result", }