set/add event
This commit is contained in:
@@ -15,6 +15,7 @@ class HookFunction(Protocol):
|
||||
|
||||
|
||||
class HookedContainer(ABC, Sized, Iterable[T], Container[T]):
|
||||
_data: MutableNesting[T]
|
||||
_path: MutableSequence[int]
|
||||
_root: MutableMapping[T] | MutableSequence[T] | None = None
|
||||
hook: HookFunction
|
||||
@@ -22,15 +23,21 @@ class HookedContainer(ABC, Sized, Iterable[T], Container[T]):
|
||||
def __repr__(self):
|
||||
return f"{self.__class__.__name__}({self._data!r})"
|
||||
|
||||
def __len__(self):
|
||||
return len(self._data)
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._data)
|
||||
|
||||
def __contains__(self, x):
|
||||
return x in self._data
|
||||
|
||||
# Sequence Methods
|
||||
# __contains__, __iter__, __reversed__, index, and count
|
||||
|
||||
@abstractmethod
|
||||
def __getitem__(self, key): ...
|
||||
|
||||
def __len__(self):
|
||||
return len(self._data)
|
||||
|
||||
# MutableSequence Methods
|
||||
# append, reverse, extend, pop, remove, and __iadd__
|
||||
|
||||
@@ -44,8 +51,8 @@ class HookedContainer(ABC, Sized, Iterable[T], Container[T]):
|
||||
if self.hook:
|
||||
self.hook(e.RemoveItemEvent(self.new_path(s), item))
|
||||
|
||||
@abstractmethod
|
||||
def insert(self, index, value): ...
|
||||
# @abstractmethod
|
||||
# def insert(self, index, value): ...
|
||||
|
||||
# Custom Methods
|
||||
|
||||
|
||||
Reference in New Issue
Block a user