New submission from Michael Robellard <m...@robellard.com>:
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=False) uploaded_by: str = None def save(self): print(self.uploaded_by) @property def uploaded_by(self): return self._uploaded_by @uploaded_by.setter def uploaded_by(self, uploaded_by): print('Setter Called with Value ', uploaded_by) self._uploaded_by = uploaded_by p = FileObject() p.save() This outputs: Setter Called with Value <property object at 0x7faeb00150b0> <property object at 0x7faeb00150b0> I would expect to get None instead Here is the StackOverflow Question where I started this: https://stackoverflow.com/questions/59623952/weird-issue-when-using-dataclass-and-property-together ---------- components: Library (Lib) messages: 359528 nosy: Michael Robellard priority: normal severity: normal status: open title: dataclass defaults and property don't work together type: behavior versions: Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39247> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com