Closed shaunc closed 3 years ago
Hi @shaunc - I think we support this case, please try my example:
from dataclasses import dataclass, field
from typing import Any, Mapping
import dacite
class Bar:
def __init__(self, i: int) -> None:
self.i = i
def build_bar(data: Any) -> Bar:
return Bar(i=data["bar_i"])
@dataclass
class Foo:
bar: Mapping[str, Bar] = field(default_factory=lambda: {})
dacite.from_dict(
data_class=Foo,
data={"bar": {"instance": {"bar_i": 1}}},
config=dacite.Config(type_hooks={Bar: build_bar})
)
I would like to use a type hook convert a type embedded in a type definition. For example: