konradhalas / dacite

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

Add support for typing.Type[...] #111

Closed tmke8 closed 3 years ago

tmke8 commented 4 years ago

This allows code like this:

from typing import Type

class A:
    pass

class B(A):
    pass

@dataclass
class Config:
    class_: Type[A]

config = from_dict(Config, {"class_": B})
tmke8 commented 4 years ago

Seems to fail on python 3.6. Will investigate.

konradhalas commented 3 years ago

Hi @thomkeh - thank you for your PR. I hope I covered your case in https://github.com/konradhalas/dacite/commit/02f1073a221e6cc320d77dd66f87ed6ba33b3cb3 and https://github.com/konradhalas/dacite/commit/aa692fea507e0946337751eb42e70acacdfef35b.