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
{{ message }}
Repository navigation
Type-narrowing Union with Literal using comparison to Literal variable #16465
I would say that this is indeed a bug. It won't be a bug in the positive case (as a class that redefines __eq__ MAY be equal to a string), but it should definitely narrow in the negative case. Here you can see that the problem manifest itself depending on if you redefined __eq__ or not:
Activity
vnmabus commentedon Nov 24, 2023
I would say that this is indeed a bug. It won't be a bug in the positive case (as a class that redefines
__eq__MAY be equal to a string), but it should definitely narrow in the negative case. Here you can see that the problem manifest itself depending on if you redefined__eq__or not:A5rocks commentedon Jan 30, 2025
Copying over my smaller reproducer from #18569:
Better narrowing with custom equality (python#20643)