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 rhettinger
Recipients eric.smith, rhettinger
Date 2018-01-13.21:26:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1515878783.18.0.467229070634.issue32546@psf.upfronthosting.co.za>
In-reply-to
Content
The following code (simplified from a real example) triggers an unexpected TypeError:

    @dataclass
    class PrioritizedItem:
        priority: 'int'
        def __eq__(self, other):
            return self.priority == other.priority

This code gives the following trackback:

    Traceback (most recent call last):
      File "/Users/raymond/Documents/tmp16.py", line 16, in <module>
        @dataclass
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 598, in dataclass
        return wrap(_cls)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 590, in wrap
        return _process_class(cls, repr, eq, order, hash, init, frozen)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 539, in _process_class
        _set_attribute(cls, '__hash__', None)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 444, in _set_attribute
        raise TypeError(f'Cannot overwrite attribute {name} '
    TypeError: Cannot overwrite attribute __hash__ in PrioritizedItem
History
Date User Action Args
2018-01-13 21:26:23rhettingersetrecipients: + rhettinger, eric.smith
2018-01-13 21:26:23rhettingersetmessageid: <1515878783.18.0.467229070634.issue32546@psf.upfronthosting.co.za>
2018-01-13 21:26:23rhettingerlinkissue32546 messages
2018-01-13 21:26:22rhettingercreate