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

2020-04-15 Thread Juan Arrivillaga
Juan Arrivillaga added the comment: But when would you want to have a descriptor as an instance attribute? Descriptors must be in the class dictionary to work: https://docs.python.org/3/reference/datamodel.html#implementing-descriptors I suppose, you could want some container class of

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

2020-01-10 Thread Juan Arrivillaga
Juan Arrivillaga added the comment: Actually, couldn't the following be a workaround, just set the property on the class after the class definition: import dataclasses import typing @dataclasses.dataclass class FileObject: uploaded_by:typing.Optional[None]=None

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

2020-01-10 Thread Juan Arrivillaga
Juan Arrivillaga added the comment: So, after glancing at the source code: https://github.com/python/cpython/blob/ce54519aa09772f4173b8c17410ed77e403f3ebf/Lib/dataclasses.py#L869 During this processing of fields, couldn't you just special case property/descriptor objects? --