Author serhiy.storchaka
Recipients rhettinger, serhiy.storchaka
Date 2020-07-28.06:34:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1595918093.33.0.049225231479.issue41416@roundup.psfhosted.org>
In-reply-to
Content
According to the documentation [1] abstract classes collections.abc.Set and collections.abc.Mapping provide mixin method __ne__. But implementations of __ne__ in these classes were removed in 3.4 (see issue21408), so the default implementation is inherited from object. The reason is that it works better with classes which override __ne__ to return non-boolean, e.g. NumPy, SymPy and sqlalchemy classes. Previously the != operator falled back to other__eq__(), now it falls back to other__ne__().

[1] https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes

But now we have a discrepancy between the decomentation and the code. According to the documentation, if we have a class which inherits from both Set and int, in that order, the __ne__ method should be inherited from class Set instead of class int. But currently it is inherited from int.

>>> import collections.abc
>>> class A(collections.abc.Set, int): pass
... 
>>> A.__ne__
<slot wrapper '__ne__' of 'int' objects>

One way to solve this -- remove __ne__ from lists of mixin methods (see issue41400). Other way -- add the __ne__ implementations which are identical to the default implementation but has preference in the inheritance. I prefer the latter.
History
Date User Action Args
2020-07-28 06:34:53serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger
2020-07-28 06:34:53serhiy.storchakasetmessageid: <1595918093.33.0.049225231479.issue41416@roundup.psfhosted.org>
2020-07-28 06:34:53serhiy.storchakalinkissue41416 messages
2020-07-28 06:34:53serhiy.storchakacreate