Closed dylanmorroll closed 1 year ago
This code works fine:
from dataclasses import dataclass from typing import Optional import dacite @dataclass class Data: present: str optional: Optional[str] data = {"present": "one"} dacite.from_dict(Data, data)
However, when using | None, which is allowed by PEP 604, it no longer works.
| None
from dataclasses import dataclass import dacite @dataclass class Data: present: str optional: str | None data = {"present": "one"} dacite.from_dict(Data, data)
This gives the following error:
dacite.exceptions.MissingValueError: missing value for field "optional"
NB: I installed this fix and am still encountering the error, so it seems to be another issue.
This is duplicate of https://github.com/konradhalas/dacite/issues/180 You are welcome to use https://pypi.org/project/dacite2/ https://github.com/idanmiara/dacite/pull/1
@dylanmorroll should be fixed now
This code works fine:
However, when using
| None
, which is allowed by PEP 604, it no longer works.This gives the following error:
dacite.exceptions.MissingValueError: missing value for field "optional"
NB: I installed this fix and am still encountering the error, so it seems to be another issue.