Describe the bugThis is issue is potentially related to #73.
If a tuple is expected, but the data contains another collection (e.g. a list), the tuple is treated as a collection, as opposed to the more specific treatment of tuples: If the tuple is expected to contain mixed values, these types are not cast correctly.
To Reproduce
from dataclasses import dataclass
import typing
from dacite import from_dict, Config
@dataclass
class A:
values: typing.Tuple[int, ...]
@dataclass
class B:
values: typing.Tuple[str, int]
from_dict(A, {"values": ["1", "2"]}, config=Config(cast=[tuple, int])) # works
from_dict(B, {"values": ["1", "2"]}, config=Config(cast=[tuple, int])) # raises WrongTypeError
Expected behavior
Neither of these examples should raise an exception.
Environment
Python version: 3.8.10 (though it should not be python specific)
Describe the bug This is issue is potentially related to #73.
If a tuple is expected, but the data contains another collection (e.g. a list), the tuple is treated as a collection, as opposed to the more specific treatment of tuples: If the tuple is expected to contain mixed values, these types are not cast correctly.
To Reproduce
Expected behavior Neither of these examples should raise an exception.
Environment
dacite
version: 1.8.0Additional context
The problem lies in the fact that the tuple-specific treatment is only used, if the data also contains a tuple.
This error only occurs if cast includes tuple. Otherwise both examples would raise an exception due to an list being used.