You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Did you mean we should check for __eq__ when going for solution 2?
If so, this could be an additional safety net for most cases. Then, the modified solution 2 would only result in wrong narrowing for subtypes that override __eq__ strangely:
Activity
hauntsaninja commentedon Nov 14, 2024
I think both 2 and 3 are fine. If we go with 3, we should look at presence of
__eq__(inthas__eq__defined, not sure why, dates back to 2015)tyralla commentedon Nov 14, 2024
Did you mean we should check for
__eq__when going for solution 2?If so, this could be an additional safety net for most cases. Then, the modified solution 2 would only result in wrong narrowing for subtypes that override
__eq__strangely:I think, for complete safety, we would have to combine looking for
__eq__with checking forfinal:Support `==`-based narrowing of Optional
Support `==`-based narrowing of Optional (python#18163)