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 AlexWaygood
Recipients AlexWaygood, ethan.furman, josh.r, rhettinger, serhiy.storchaka, steven.daprano, terry.reedy, veky, xtreak
Date 2021-09-20.15:33:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The following code now leads to a `DeprecationWarning`, but I am unclear why it should.

>>> from enum import Enum
>>> class CardColour(Enum):
...     """Enumeration of the two colours in a pack of cards."""
... 	BLACK = 'black'
... 	RED = 'red'
... 	def other_colour(self):
...         """Given one colour, get the other one."""
... 	    return next(filter(self.__ne__, CardColour))
>>> CardColour.BLACK.other_colour()
<input>:5: DeprecationWarning: NotImplemented should not be used in a boolean context
<CardColour.RED: 'red'>

If I change the last line of `other_colour` to either `return next(colour for colour in CardColour if colour != self)` or `return next(colour for colour in CardColour if colour is not self)`, the warning goes away.

Is this intended behaviour?
Date User Action Args
2021-09-20 15:33:49AlexWaygoodsetrecipients: + AlexWaygood, rhettinger, terry.reedy, steven.daprano, ethan.furman, serhiy.storchaka, josh.r, veky, xtreak
2021-09-20 15:33:49AlexWaygoodsetmessageid: <>
2021-09-20 15:33:49AlexWaygoodlinkissue35712 messages
2021-09-20 15:33:49AlexWaygoodcreate