diff --git a/dataclass_wizard/errors.py b/dataclass_wizard/errors.py index ba2b39f2..354bb691 100644 --- a/dataclass_wizard/errors.py +++ b/dataclass_wizard/errors.py @@ -101,7 +101,7 @@ def message(self) -> str: obj_type=self.name(self.obj_type)) if self.json_object: - self.kwargs['json_object'] = json.dumps(self.json_object) + self.kwargs['json_object'] = json.dumps(self.json_object, default=str) if self.kwargs: sep = '\n ' @@ -168,7 +168,7 @@ def name(obj) -> str: def message(self) -> str: msg = self._TEMPLATE.format( cls=self.class_name, - json_string=json.dumps(self.obj), + json_string=json.dumps(self.obj, default=str), e=self.base_error, fields=self.fields, missing_fields=self.missing_fields) @@ -217,7 +217,7 @@ def name(obj) -> str: def message(self) -> str: msg = self._TEMPLATE.format( cls=self.class_name, - json_string=json.dumps(self.obj), + json_string=json.dumps(self.obj, default=str), fields=self.fields, json_key=self.json_key) @@ -255,7 +255,7 @@ def message(self) -> str: msg = self._TEMPLATE.format( cls=self.class_name, nested_cls=self.nested_class_name, - json_string=json.dumps(self.obj), + json_string=json.dumps(self.obj, default=str), field=self.field_name, o=self.obj, ) diff --git a/dataclass_wizard/parsers.py b/dataclass_wizard/parsers.py index 23cbb599..2682c229 100644 --- a/dataclass_wizard/parsers.py +++ b/dataclass_wizard/parsers.py @@ -90,7 +90,7 @@ def __contains__(self, item) -> bool: type. Checks that the item is incorporated in the given expected values of the Literal. """ - return item in self.value_to_type.keys() + return item in self.value_to_type def __call__(self, o: Any) -> M: """