Return NotImplemented for unsupported comparisons#5547
Return NotImplemented for unsupported comparisons#5547RazerM wants to merge 6 commits intoplotly:mainfrom
Conversation
|
Hi @RazerM, thanks for the contribution, and thanks for your patience awaiting review! I'm trying to make sure I understand the consequences of this change. It seems that by returning I'm having trouble thinking of a scenario where that would be helpful. It's possibly something that could be useful to us internally within plotly.py, but we haven't encountered a need for it yet to my knowledge. Do you have a scenario on your end that would benefit from this change? |
Yes, but they can already do that as long as they're on the LHS. plotly should return Some use cases are:
See also django/django#11808, sympy/sympy#13078 for examples in other popular projects. |
Link to issue
Closes #5546
Description of change
Updated the
__eq__implementations to returnNotImplementedinstead ofFalsewhen comparing against an unsupported type. This aligns with Python's data model and allows the other operand to handle the comparison.Demo
N/A
Testing strategy
Additional information (optional)
https://docs.python.org/3.14/reference/datamodel.html#object.__eq__
Guidelines