Closed das-intensity closed 1 year ago
@das-intensity thank you for your PR. It looks very good, but it doesn't work with this case:
def test_from_dict_with_optional_non_init_field():
@dataclass
class X:
s: Optional[str] = field(init=False)
x = X()
x.s = None
result = from_dict(X, {})
assert result == x
My solution (https://github.com/konradhalas/dacite/commit/667dfbae0df04a963f5b64db5cdd86ba38d9695e) covers both cases.
Small fix to
from_dict
to fix the case where:data
dict doesn't contain this fieldTest
tests/core/test_frozen_non_init_var::test_from_dict_with_frozen_non_init_var_with_default
addedcloses #195