from dataclasses import dataclass
from typing import NewType
import dacite
MyStr = NewType("MyStr", str)
@dataclass
class Data:
my_str: MyStr
dacite.from_dict(Data, {"my_str": "foo-bar"})
Traceback (most recent call last):
File "<input>", line 1, in <module>
dacite.from_dict(Data, {"my_str": "foo-bar"})
File "dacite.py", line 103, in from_dict
if not _is_instance(field.type, value):
File "dacite.py", line 337, in _is_instance
return isinstance(value, t)
TypeError: isinstance() arg 2 must be a type or tuple of types
Dacite currently does not support the "NewType" fields. The problem is in the _is_instance function. Please see the related pull request.
Example:
Dacite currently does not support the "NewType" fields. The problem is in the
_is_instance
function. Please see the related pull request.