[issue39247] dataclass defaults and property don't work together

2021-10-21 Thread Michael Robellard
Michael Robellard added the comment: An example of multiple descriptors would be to have: @cached_property @property def expensive_calc(self): #Do something expensive -- ___ Python tracker <https://bugs.python.org/issue39

[issue39247] dataclass defaults and property don't work together

2021-10-21 Thread Michael Robellard
Michael Robellard added the comment: I can confirm that Juan Arrivillaga (juanpa.arrivillaga) workaround does work. Given that it works, then wouldn't it be relatively trivial to do what Thomas701 suggests and add a descriptor parameter to fields. Then apply the descriptor after al

[issue39247] dataclass defaults and property don't work together

2021-06-05 Thread Michael Robellard
Michael Robellard added the comment: The sample I uploaded doesn't do any processing, but the use case originally had some logic inside the property getter/setter, would the alias idea allow for that? The purpose of the property is to add some logic to compute the value if it ha

[issue39247] dataclass defaults and property don't work together

2020-01-07 Thread Michael Robellard
New submission from Michael Robellard : I ran into a strange issue while trying to use a dataclass together with a property. I have it down to a minumum to reproduce it: import dataclasses @dataclasses.dataclass class FileObject: _uploaded_by: str = dataclasses.field(default=None, init