Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

dataclass does not accept union of dataclasses? #251

Open
victorgabillon opened this issue Dec 22, 2023 · 0 comments
Open

dataclass does not accept union of dataclasses? #251

victorgabillon opened this issue Dec 22, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@victorgabillon
Copy link

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

  • Python version: 3.10
  • dacite version: 1.8.1
@victorgabillon victorgabillon added the bug Something isn't working label Dec 22, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant