From 5b360a8a0672c0d1274e2676569d44d77c6ca65d Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sat, 10 Jun 2023 22:50:54 +0300 Subject: [PATCH] insndb/core: make Dict almost immutable --- src/openpower/insndb/core.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/openpower/insndb/core.py b/src/openpower/insndb/core.py index d0425ff8..b9f681b6 100644 --- a/src/openpower/insndb/core.py +++ b/src/openpower/insndb/core.py @@ -124,6 +124,27 @@ class Dict(Node, dict): cls.__datatype = datatype return super().__init_subclass__() + def __hash__(self): + return hash(tuple(sorted(self.items()))) + + def clear(self): + raise NotImplementedError() + + def __delitem__(self, key): + raise NotImplementedError() + + def __setitem__(self, key, value): + raise NotImplementedError() + + def popitem(self) -> tuple: + raise NotImplementedError() + + def pop(self, key, default=None): + raise NotImplementedError() + + def update(self, entry, **kwargs): + raise NotImplementedError() + @walkmethod def walk(clsself, match=None): if match is None: @@ -756,9 +777,6 @@ class Fields(Dict, datatype=type("Bits", (Tuple,), {}, datatype=int)): return super().__init__(mapping) - def __hash__(self): - return hash(tuple(sorted(self.items()))) - def __iter__(self): yield from self.__mapping.items() -- 2.30.2