From 25f931753205247c64c4bff03039080ed670939e Mon Sep 17 00:00:00 2001 From: Christian Cwienk Date: Fri, 20 Jan 2023 16:33:02 +0100 Subject: [PATCH] do not try to parse datetime-objects --- bindings-python/gci/componentmodel.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bindings-python/gci/componentmodel.py b/bindings-python/gci/componentmodel.py index a93dc55c..b9037308 100644 --- a/bindings-python/gci/componentmodel.py +++ b/bindings-python/gci/componentmodel.py @@ -544,6 +544,13 @@ def from_dict( component_descriptor_dict: dict, validation_mode: ValidationMode = ValidationMode.NONE, ): + def dateparse(v): + if not v: + return None + if isinstance(v, datetime.datetime): + return v + return dateutil.parser.isoparse(v) + component_descriptor = dacite.from_dict( data_class=ComponentDescriptor, data=component_descriptor_dict, @@ -565,8 +572,7 @@ def from_dict( AccessType: functools.partial( enum_or_string, enum_type=AccessType ), - datetime.datetime: - lambda v: dateutil.parser.isoparse(v) if v else None, + datetime.datetime: dateparse, }, ) )