konradhalas / dacite

Simple creation of data classes from dictionaries.
MIT License
1.72k stars 106 forks source link

dataclass does not accept union of dataclasses? #251

Open victorgabillon opened 9 months ago

victorgabillon commented 9 months ago

thanks for this amazing library!

Describe the bug It is not possible it seems to have the dataclass argument of the from_dict method to accept a union of class

To Reproduce

@dataclass class A: x: str

@dataclass class B: y: int

data = { 'y': 1 }

result = from_dict(data_class=A|B, data=data)

Expected behavior result woud be B(y=1)

Environment