Describe the bug
When dacite tries to deserialize a field as a list which in reality is a dict, the error message is confusing and does not indicate which field the problem originates from.
To Reproduce
from dataclasses import dataclass
from typing import List
from dacite import from_dict
@dataclass
class Sub:
name: str
@dataclass
class Example:
xs: List[Sub]
from_dict(data_class=Example, data={"xs": {"name": "foo"}})
# ValueError: dictionary update sequence element #0 has length 4; 2 is required
Expected behavior
An error that indicates which field caused the problem, and maybe some detail on what happened, e.g.
dacite.exceptions.WrongTypeError: wrong value type for field "xs" - should be "List" instead of value "{'name': 'foo'}" of type "dict"
Environment
- Python version: 3.14.0
dacite version: 1.9.2
Additional context
Error originates here, where the following kind of call happens (based on the above example). It seems like maybe the condition on L160 is too broad?
dict(["name"])
# ValueError: dictionary update sequence element #0 has length 4; 2 is required
Describe the bug
When dacite tries to deserialize a field as a list which in reality is a
dict, the error message is confusing and does not indicate which field the problem originates from.To Reproduce
Expected behavior
An error that indicates which field caused the problem, and maybe some detail on what happened, e.g.
Environment
daciteversion: 1.9.2Additional context
Error originates here, where the following kind of call happens (based on the above example). It seems like maybe the condition on L160 is too broad?