diff --git a/misc/utils.py b/misc/utils.py index fd1238f..1c2edae 100644 --- a/misc/utils.py +++ b/misc/utils.py @@ -11,6 +11,8 @@ class SaveFileObject(): def asdict(self): return asdict(self) def update(self, new): + if new is None: + new=dict() for key, value in new.items(): if hasattr(self, key): setattr(self, key, value) @@ -57,7 +59,7 @@ class SaveFileMapping(Mapping): if not isinstance(data,SaveFileObject): raise TypeError("data elements should be derived from SaveFileObject") if not callable(getattr(data,"asdict",None)): - raise TypeError("Dataelements need a method to_dict that returns a dict") + raise TypeError("Dataelements need a method asdict that returns a dict this should be out of the box if you use dataclasses") #if not callable(getattr(data.__class__,"from_dict",None)): # raise TypeError("Dataelements need a method to_dict that returns a dict")