Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
do not try to parse datetime-objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ccwienk committed Jan 20, 2023
1 parent a6b3df9 commit 25f9317
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bindings-python/gci/componentmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
)
)
Expand Down

0 comments on commit 25f9317

Please sign in to comment.