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
Non overlapping inclusion check for literal types #11313
Right now mypy spots an error on the first if condition but it would be great if it could also complain on the second one which seems a better expression of the first test:
in check is not support right now, as far as I remember. It could be a cool feature. And quite easy one.
We can just translate x in ('a', 'b') expression into x == 'a' or x == 'b'. And everything should work the same way.
Activity
sobolevn commentedon Oct 12, 2021
incheck is not support right now, as far as I remember. It could be a cool feature. And quite easy one.We can just translate
x in ('a', 'b')expression intox == 'a' or x == 'b'. And everything should work the same way.I will look into it.
sobolevn commentedon Nov 9, 2021
Turned out it is not as easy. Simple "translate" did not work. Several reasons:
inis not identical to two==. There might be__contains__defined, but not__eq__. Or they might be incompatibleintgr commentedon Aug 19, 2022
This issue title is misleading, should be renamed to mention
inoperator, nothing to do with literal types.sterliakov commentedon Dec 20, 2024
Similar/duplicate of #3229?