diff --git a/python/pycrdt/_array.py b/python/pycrdt/_array.py index 9fd58eb..b746905 100644 --- a/python/pycrdt/_array.py +++ b/python/pycrdt/_array.py @@ -15,6 +15,7 @@ class Array(BaseType): """ A collection used to store data in an indexed sequence structure, similar to a Python `list`. """ + _prelim: list | None _integrated: _Array | None @@ -371,6 +372,7 @@ class ArrayEvent(BaseEvent): delta (list[dict[str, Any]]): A list of items describing the changes. path (list[int | str]): A list with the indices pointing to the array that was changed. """ + __slots__ = "target", "delta", "path" diff --git a/python/pycrdt/_map.py b/python/pycrdt/_map.py index 5f7e5dc..d1fe560 100644 --- a/python/pycrdt/_map.py +++ b/python/pycrdt/_map.py @@ -15,6 +15,7 @@ class Map(BaseType): """ A collection used to store key-value entries in an unordered manner, similar to a Python `dict`. """ + _prelim: dict | None _integrated: _Map | None @@ -298,6 +299,7 @@ class MapEvent(BaseEvent): delta (list[dict[str, Any]]): A list of items describing the changes. path (list[int | str]): A list with the indices pointing to the map that was changed. """ + __slots__ = "target", "keys", "path" diff --git a/python/pycrdt/_sync.py b/python/pycrdt/_sync.py index c5fc925..dc4d3f6 100644 --- a/python/pycrdt/_sync.py +++ b/python/pycrdt/_sync.py @@ -14,6 +14,7 @@ class YMessageType(IntEnum): SYNC: A message type used for synchronizing documents. AWARENESS: A message type used for the awareness protocol. """ + SYNC: int = 0 AWARENESS: int = 1 @@ -28,6 +29,7 @@ class YSyncMessageType(IntEnum): consisting of all missing updates and all deletions. SYNC_UPDATE: A synchronization message type used to send document updates. """ + SYNC_STEP1: int = 0 SYNC_STEP2: int = 1 SYNC_UPDATE: int = 2 @@ -111,6 +113,7 @@ class Decoder: """ A decoder capable of reading messages from a byte stream. """ + def __init__(self, stream: bytes): """ Args: diff --git a/python/pycrdt/_text.py b/python/pycrdt/_text.py index fd0aebf..784ab51 100644 --- a/python/pycrdt/_text.py +++ b/python/pycrdt/_text.py @@ -15,6 +15,7 @@ class Text(BaseType): """ A shared data type used for collaborative text editing, similar to a Python `str`. """ + _prelim: str | None _integrated: _Text | None @@ -264,6 +265,7 @@ class TextEvent(BaseEvent): delta (list[dict[str, Any]]): A list of items describing the changes. path (list[int | str]): A list with the indices pointing to the text that was changed. """ + __slots__ = "target", "delta", "path" diff --git a/python/pycrdt/_transaction.py b/python/pycrdt/_transaction.py index f8062c2..a73648f 100644 --- a/python/pycrdt/_transaction.py +++ b/python/pycrdt/_transaction.py @@ -21,6 +21,7 @@ class Transaction: ... ``` """ + _doc: Doc _txn: _Transaction | None _leases: int @@ -87,7 +88,7 @@ def __exit__( def origin(self) -> Any: """ The origin of the transaction. - + Raises: RuntimeError: No current transaction. """ @@ -114,6 +115,7 @@ class NewTransaction(Transaction): ... ``` """ + async def __aenter__(self) -> Transaction: if self._doc._allow_multithreading: if not await to_thread.run_sync( diff --git a/python/pycrdt/_undo.py b/python/pycrdt/_undo.py index 5c2eb16..0c59e38 100644 --- a/python/pycrdt/_undo.py +++ b/python/pycrdt/_undo.py @@ -24,6 +24,7 @@ class UndoManager: Changes can be undone/redone by batches using time intervals. It is possible to include/exclude changes by transaction origin in undo/redo operations. """ + def __init__( self, *, @@ -37,7 +38,7 @@ def __init__( scopes: A list of shared types the undo manager will work with. capture_timeout_millis: A time interval for grouping changes that will be undone/redone. - + Raises: RuntimeError: UndoManager must be created with doc or scopes. """ diff --git a/python/pycrdt/_update.py b/python/pycrdt/_update.py index b82deda..e5068ea 100644 --- a/python/pycrdt/_update.py +++ b/python/pycrdt/_update.py @@ -34,7 +34,7 @@ def get_update(update: bytes, state: bytes) -> bytes: def merge_updates(*updates: bytes) -> bytes: """ Returns an update consisting of a combination of all given updates. - + Args: updates: The updates to merge.