This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Michael Robellard
Recipients Michael Robellard
Date 2020-01-07.17:35:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578418537.56.0.0565923550129.issue39247@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2020-01-07 17:35:37Michael Robellardsetrecipients: + Michael Robellard
2020-01-07 17:35:37Michael Robellardsetmessageid: <1578418537.56.0.0565923550129.issue39247@roundup.psfhosted.org>
2020-01-07 17:35:37Michael Robellardlinkissue39247 messages
2020-01-07 17:35:36Michael Robellardcreate