From c1b049643ce5d5da55b3af925da04776a9136d7c Mon Sep 17 00:00:00 2001 From: Nicolas Brichet Date: Thu, 3 Oct 2024 21:49:02 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: David Brochart <4711805+davidbrochart@users.noreply.github.com> --- jupyter_ydoc/ybasedoc.py | 13 ++++++++----- jupyter_ydoc/yblob.py | 3 +++ jupyter_ydoc/ynotebook.py | 3 +++ jupyter_ydoc/yunicode.py | 3 +++ pyproject.toml | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/jupyter_ydoc/ybasedoc.py b/jupyter_ydoc/ybasedoc.py index 2eaaa70..56cd1c5 100644 --- a/jupyter_ydoc/ybasedoc.py +++ b/jupyter_ydoc/ybasedoc.py @@ -26,12 +26,14 @@ def __init__(self, ydoc: Optional[Doc] = None, awareness: Optional[Awareness] = :param ydoc: The :class:`pycrdt.Doc` that will hold the data of the document, if provided. :type ydoc: :class:`pycrdt.Doc`, optional. + :param awareness: The :class:`pycrdt.Awareness` that share non persistent data + between clients. + :type awareness: :class:`pycrdt.Awareness`, optional. """ if ydoc is None: self._ydoc = Doc() else: self._ydoc = ydoc - self._awareness = awareness self._ystate = self._ydoc.get("state", type=Map) @@ -80,19 +82,20 @@ def ydoc(self) -> Doc: @property def awareness(self) -> Awareness | None: """ - Return the awareness. + Returns the awareness. :return: The document's awareness. - :rtype: :class:`pycrdt_websocket.awareness.Awareness` + :rtype: :class:`pycrdt.Awareness` or None. """ return self._awareness @awareness.setter - def awareness(self, value: Awareness): + def awareness(self, value: Awareness) -> None: """ Sets the awareness. - :param: The awareness. + :param value: The awareness to set. + :type value: :class:`pycrdt.Awareness`. """ self._awareness = value diff --git a/jupyter_ydoc/yblob.py b/jupyter_ydoc/yblob.py index 545eb5c..fe58a49 100644 --- a/jupyter_ydoc/yblob.py +++ b/jupyter_ydoc/yblob.py @@ -30,6 +30,9 @@ def __init__(self, ydoc: Optional[Doc] = None, awareness: Optional[Awareness] = :param ydoc: The :class:`pycrdt.Doc` that will hold the data of the document, if provided. :type ydoc: :class:`pycrdt.Doc`, optional. + :param awareness: The :class:`pycrdt.Awareness` that share non persistent data + between clients. + :type awareness: :class:`pycrdt.Awareness`, optional. """ super().__init__(ydoc, awareness) self._ysource = self._ydoc.get("source", type=Map) diff --git a/jupyter_ydoc/ynotebook.py b/jupyter_ydoc/ynotebook.py index 3414038..92db9a7 100644 --- a/jupyter_ydoc/ynotebook.py +++ b/jupyter_ydoc/ynotebook.py @@ -53,6 +53,9 @@ def __init__(self, ydoc: Optional[Doc] = None, awareness: Optional[Awareness] = :param ydoc: The :class:`pycrdt.Doc` that will hold the data of the document, if provided. :type ydoc: :class:`pycrdt.Doc`, optional. + :param awareness: The :class:`pycrdt.Awareness` that share non persistent data + between clients. + :type awareness: :class:`pycrdt.Awareness`, optional. """ super().__init__(ydoc, awareness) self._ymeta = self._ydoc.get("meta", type=Map) diff --git a/jupyter_ydoc/yunicode.py b/jupyter_ydoc/yunicode.py index 5005760..ba35d4e 100644 --- a/jupyter_ydoc/yunicode.py +++ b/jupyter_ydoc/yunicode.py @@ -29,6 +29,9 @@ def __init__(self, ydoc: Optional[Doc] = None, awareness: Optional[Awareness] = :param ydoc: The :class:`pycrdt.Doc` that will hold the data of the document, if provided. :type ydoc: :class:`pycrdt.Doc`, optional. + :param awareness: The :class:`pycrdt.Awareness` that share non persistent data + between clients. + :type awareness: :class:`pycrdt.Awareness`, optional. """ super().__init__(ydoc, awareness) self._ysource = self._ydoc.get("source", type=Text) diff --git a/pyproject.toml b/pyproject.toml index c27b19d..0e1854c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ dev = [ ] test = [ "pre-commit", - "pytest >=9.16", + "pytest", "pytest-asyncio", "websockets >=10.0", "pycrdt-websocket >=0.14.1,<0.15.0",