You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dacite failes to recognize a nested class structure involving tuples and lists.
To Reproduce
from typing import List, Tuple
from dataclasses import dataclass
from dacite import from_dict, Config
@dataclass
class A:
i: List[str]
t: str
@dataclass
class B:
m: Tuple[str, A]
assert from_dict(
data_class=B,
data={"m": ["a", {"i": [], "t": "foo"}]},
config=Config(cast=[tuple])
) == B(m=('a', A(i=[], t='foo')))
Running the code yields:
File ".venv/lib/python3.10/site-packages/dacite/core.py", line 69, in from_dict
raise WrongTypeError(field_path=field.name, field_type=field_type, value=value)
dacite.exceptions.WrongTypeError: wrong value type for field "m" - should be "Tuple" instead of value "('a', {'i': [], 't': 'foo'})" of type "tuple"
Expected behavior
No errors Environment
Python version: 3.10.3
dacite version: 1.8.0
Additional context
The code works just fine with dacite 1.6.0
The text was updated successfully, but these errors were encountered:
Describe the bug
Dacite failes to recognize a nested class structure involving tuples and lists.
To Reproduce
Running the code yields:
Expected behavior
No errors
Environment
dacite
version: 1.8.0Additional context
The code works just fine with dacite 1.6.0
The text was updated successfully, but these errors were encountered: