Skip to content

Commit

Permalink
JSON Schema fixes + Supporting parsing dates/date-times from qube-con…
Browse files Browse the repository at this point in the history
…fig.json (#450)
  • Loading branch information
robons authored Apr 22, 2022
1 parent 7633396 commit e0b5b59
Show file tree
Hide file tree
Showing 17 changed files with 697 additions and 615 deletions.
338 changes: 171 additions & 167 deletions csvcubed-devtools/poetry.lock

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions csvcubed-models/csvcubedmodels/dataclassbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from dataclasses import Field, _MISSING_TYPE, fields, asdict, dataclass
from typing import List, Any, get_type_hints, Dict, Set, Type

from dateutil import parser


class DataClassFromDictValueError(ValueError):
...
Expand Down Expand Up @@ -198,8 +200,8 @@ def _get_value_for_typed_field(
elif isinstance(val, str) and issubclass(typing_hint, datetime.date):
# ISO-8601 conversion.
if issubclass(typing_hint, datetime.datetime):
return datetime.datetime.fromisoformat(val)
return datetime.date.fromisoformat(val)
return parser.isoparse(val)
return parser.isoparse(val).date()

raise DataClassFromDictValueError(
f"Could not match {val} with static type {typing_hint}"
Expand Down
Loading

0 comments on commit e0b5b59

Please sign in to comment.