[issue32546] Unusual TypeError with dataclass decorator

2018-01-27 Thread Eric V. Smith

Eric V. Smith  added the comment:

This has been fixed as part of #32513.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32546] Unusual TypeError with dataclass decorator

2018-01-13 Thread Eric V. Smith

Eric V. Smith  added the comment:

No matter what happens with #32513, I think the right thing to do in this case 
is to not error if trying to set __hash__ to None, if it already is None in 
__dict__.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32546] Unusual TypeError with dataclass decorator

2018-01-13 Thread Eric V. Smith

Eric V. Smith  added the comment:

Thanks.

I'm going to be changing the errors as part of #32513, but I'll make sure to 
cover this case better.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com




[issue32546] Unusual TypeError with dataclass decorator

2018-01-13 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I think the error message here can be improved to explain why is being raised.  
Otherwise the cause isn't self-evident.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32546] Unusual TypeError with dataclass decorator

2018-01-13 Thread Raymond Hettinger

New submission from Raymond Hettinger :

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 
@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

--
assignee: eric.smith
components: Library (Lib)
files: data_class_type_error.py
messages: 309901
nosy: eric.smith, rhettinger
priority: normal
severity: normal
status: open
title: Unusual TypeError with dataclass decorator
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file47384/data_class_type_error.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com