Closed TBS1996 closed 1 year ago
did you try to use dacite.Config to automatically cast the integer to Enum ?
class FooEnum(IntEnum):
value = 1
@dataclass
class Foo:
foo_enum: FooEnum
dacite.from_dict(data_class=Foo, data={'foo_enum': 1}, config=dacite.Config(cast=[FooEnum])
Dacite will then automatically cast json field foo_enum to FooEnum type.
@gmonacho thank you for the good answer :)
an IntEnum will be saved in json as a simple int, when loading a dataclass with an IntEnum it should be able to recognize the int as an intenum, but instead i get an error.