Skip to content

Commit

Permalink
Replace NotImplemented with NotImplementedError
Browse files Browse the repository at this point in the history
  • Loading branch information
akubera committed Jun 23, 2024
1 parent 40e9d6c commit 4dd8eb4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/automerge/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __getitem__(self, key: int) -> ProxyThing: ...
@overload
def __getitem__(self, key: slice) -> Sequence[ProxyThing]: ...
def __getitem__(self, key: Union[int, slice]) -> Union[ProxyThing, Sequence[ProxyThing]]:
if not isinstance(key, int): raise NotImplemented
if not isinstance(key, int): raise NotImplementedError
x = self._doc.get(self._obj_id, key, self._heads)
if x is None: raise IndexError()
return self._maybe_wrap(x)
Expand Down Expand Up @@ -127,15 +127,15 @@ def __delitem__(self, key: str) -> None:
self._tx.delete(self._obj_id, key)

def __iter__(self) -> Iterator[str]:
raise NotImplemented
raise NotImplementedError

class ListWriteProxy(WriteProxy, MutableSequence[MutableProxyThing]):
@overload
def __getitem__(self, key: int) -> MutableProxyThing: ...
@overload
def __getitem__(self, key: slice) -> MutableSequence[MutableProxyThing]: ...
def __getitem__(self, key: Union[int, slice]) -> Union[MutableProxyThing, MutableSequence[MutableProxyThing]]:
if not isinstance(key, int): raise NotImplemented
if not isinstance(key, int): raise NotImplementedError
x = self._tx.get(self._obj_id, key, self._heads)
if x is None: return None
value, obj_id = x
Expand All @@ -153,7 +153,7 @@ def __setitem__(self, key: int, value: MutableProxyThing) -> None: ...
@overload
def __setitem__(self, key: slice, value: Iterable[MutableProxyThing]) -> None: ...
def __setitem__(self, idx: Union[int, slice], value: Union[MutableProxyThing, Iterable[MutableProxyThing]]) -> None:
if not isinstance(idx, int): raise NotImplemented
if not isinstance(idx, int): raise NotImplementedError
if isinstance(value, MutableMapping):
if idx >= self._tx.length(self._obj_id, self._heads):
obj_id = self._tx.insert_object(self._obj_id, idx, core.ObjType.Map)
Expand Down Expand Up @@ -193,11 +193,11 @@ def __delitem__(self, idx: int) -> None: ...
@overload
def __delitem__(self, idx: slice) -> None: ...
def __delitem__(self, idx: Union[int, slice]) -> None:
if not isinstance(idx, int): raise NotImplemented
if not isinstance(idx, int): raise NotImplementedError
self._tx.delete(self._obj_id, idx)

def insert(self, idx: int, value: Union[core.ScalarValue, MutableMapping[str, MutableProxyThing], MutableSequence[MutableProxyThing], None]) -> None:
if not isinstance(idx, int): raise NotImplemented
if not isinstance(idx, int): raise NotImplementedError
if isinstance(value, MutableMapping):
obj_id = self._tx.insert_object(self._obj_id, idx, core.ObjType.Map)
m = MapWriteProxy(self._tx, obj_id, self._heads)
Expand Down Expand Up @@ -251,4 +251,3 @@ def __init__(self, actor_id: Optional[ActorId] = None) -> None:
def change(self) -> Iterator[MapWriteProxy]:
with self._doc.transaction() as tx:
yield MapWriteProxy(tx, core.ROOT, None)

0 comments on commit 4dd8eb4

Please sign in to comment.