dacite
dacite copied to clipboard
improve Data typing
Data does not need to be a Mapping[str, Any] but just object with keys and __getitem__
This make it possible to use some dict-like object, for example asyncpg.Record without typing error.
for example, asyncpg.Record has keys() -> Iterable[str] bot not keys() -> KeysView[str], and we convert keys to set so it also doesn't need keys to return KeysView
before:
row = pg.fetchrow(...)
v = from_dict(..., row) # mypy raise typing error, asyncpg.Record doesn't satisfy Mapping[str, Any]