Skip to content

Commit b40ae93

Browse files
committed
Make YBaseDoc an abstract base class
1 parent 3ac8776 commit b40ae93

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

jupyter_ydoc/ydoc.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import copy
2+
from abc import ABC, abstractmethod
23
from typing import Any, Dict
34
from uuid import uuid4
45

@@ -7,7 +8,7 @@
78
from .utils import cast_all
89

910

10-
class YBaseDoc:
11+
class YBaseDoc(ABC):
1112
def __init__(self, ydoc: Y.YDoc):
1213
self._ydoc = ydoc
1314
self._ystate = self._ydoc.get_map("state")
@@ -38,14 +39,17 @@ def dirty(self, value: bool) -> None:
3839
with self._ydoc.begin_transaction() as t:
3940
self._ystate.set(t, "dirty", value)
4041

42+
@abstractmethod
4143
def get(self):
42-
raise RuntimeError("Y document get not implemented")
44+
pass
4345

46+
@abstractmethod
4447
def set(self, value):
45-
raise RuntimeError("Y document set not implemented")
48+
pass
4649

50+
@abstractmethod
4751
def observe(self, callback):
48-
raise RuntimeError("Y document observe not implemented")
52+
pass
4953

5054
def unobserve(self):
5155
for k, v in self._subscriptions.items():

0 commit comments

Comments
 (0)