Closed kwist-sgr closed 1 year ago
Describe the bug default_factory is called only once if a field absent in the data
default_factory
To Reproduce
#!/usr/bin/env python from dataclasses import field, dataclass from dacite import from_dict @dataclass class A: name: str items: list[str] = field(default_factory=list) if __name__ == '__main__': a1 = from_dict(A, {'name': 'a1'}) a2 = from_dict(A, {'name': 'a2'}) print('Test identity:', a1.items is a2.items)
Output
Test identity: True
Expected behavior items shouldn't be identical. dacite v1.7.0 works as expected
items
dacite v1.7.0
Test identity: False
Environment
dacite
Looks like a good v1.8.1 candidate. Thanks for reporting!.
v1.8.1
@mciszczon is there a plan for 1.8.1?
@ehiggs Released today :)
Describe the bug
default_factory
is called only once if a field absent in the dataTo Reproduce
Output
Expected behavior
items
shouldn't be identical.dacite v1.7.0
works as expectedEnvironment
dacite
version: 1.8.0