pruning
This commit is contained in:
20
src/hooked_containers/mapping.py
Normal file
20
src/hooked_containers/mapping.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from collections.abc import Callable, MutableMapping, MutableSequence, Sequence
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from . import events as e
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
class HookedMapping(Generic[T], MutableMapping[T, T | MutableSequence[T], MutableMapping[T]]):
|
||||
_data: MutableSequence[T]
|
||||
_path: MutableSequence[int]
|
||||
hook: Callable[[e.ChangeEvent[T]], None] | None
|
||||
|
||||
def __init__(self, hook, existing: MutableMapping[T], path: Sequence[int] | None = None):
|
||||
self.hook = hook
|
||||
self._data = existing
|
||||
self._path = list(path) if path is not None else []
|
||||
|
||||
def __setitem__(self, key):
|
||||
return
|
||||
Reference in New Issue
Block a user