[New-bugs-announce] [issue28263] Python 2.7's `-3` flag warns about __eq__ being implemented without __hash__ even if __hash__ is never accessed.

Roy Williams report at bugs.python.org
Fri Sep 23 19:23:01 EDT 2016


New submission from Roy Williams:

I'm finding the -3 flag to be super useful at identifying problems with code when porting to Python 3.  One of the most common failures, however, is "DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__ in 3.x".  While implementing __eq__ without implementing __hash__ is very much an anti-pattern, this warning would be much less noisy if it could be thrown at time of access (like the __getslice__ warning) instead of time of declaration. 

See Also:
https://github.com/nedbat/coveragepy/pull/17
http://bugs.python.org/issue28260

----------
components: Interpreter Core
messages: 277305
nosy: Roy Williams
priority: normal
severity: normal
status: open
title: Python 2.7's `-3` flag warns about __eq__ being implemented without __hash__ even if __hash__ is never accessed.
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28263>
_______________________________________


More information about the New-bugs-announce mailing list