diff --git a/src/hooked_containers/mapping.py b/src/hooked_containers/mapping.py index c1162c8..86ba627 100644 --- a/src/hooked_containers/mapping.py +++ b/src/hooked_containers/mapping.py @@ -27,7 +27,7 @@ class HookedMapping(HookedContainer[T], MutableMapping[T, MutableNesting[T]]): case MutableMapping() as mapping: new_path = copy(self._path) new_path.append(key) - return HookedMapping(self.hook, existing=mapping, path=new_path) + return type(self)(self.hook, existing=mapping, path=new_path) case MutableSequence() as seq: new_path = copy(self._path) new_path.append(key) diff --git a/src/hooked_containers/sequence.py b/src/hooked_containers/sequence.py index 5c439b0..dd190e5 100644 --- a/src/hooked_containers/sequence.py +++ b/src/hooked_containers/sequence.py @@ -27,7 +27,7 @@ class HookedList(HookedContainer[T], MutableSequence[T]): new_path = copy(self._path) new_path.append(s) # print(new_path) - return HookedList(self.hook, existing=seq, path=new_path) + return type(self)(self.hook, existing=seq, path=new_path) case _ as item: return item