Closed bpeake-illuscio closed 5 years ago
Currently, using a dataclasses which include non-init fields throws an error.
Example (python 3.7):
>>> import dacite >>> from dataclasses import dataclass, field >>> >>> @dataclass >>> class A: ... number: int ... text: str ... ... post: str = field(init=False) ... >>> >>> data = { ... "_data_type": "A", ... "number": 1, ... "text": "hello", ... "post": "gotcha!" ... } >>> dacite.from_dict(A, data) Traceback (most recent call last): File "<input>", line 1, in <module> File "/Users/williampeake/venvs/isle_collections-py-37/lib/python3.7/site-packages/dacite.py", line 96, in from_dict return data_class(**values) TypeError: __init__() got an unexpected keyword argument 'post'
Made a PR that fixes this here: https://github.com/konradhalas/dacite/pull/14
Fixed by https://github.com/konradhalas/dacite/commit/686570b899c1fd36062dda0e886af282d93911e2
Currently, using a dataclasses which include non-init fields throws an error.
Example (python 3.7):