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
enumerate causes incompatible type mypy error #11934
This is yet another case where mypy's choice to use join rather than union causes problems. Pyright uses only unions, never joins, so it produces the expected result in this case.
Has there been any serious discussion of changing mypy's behavior to use unions instead of joins? I can't think of any case where joins are preferable, and there are many cases where unions are better because they retain more detailed type information.
Activity
sobolevn commentedon Jan 9, 2022
You can try this (if you are using
python>=3.9):But, I agree that automatically infering
str | inthere can be a good feature. But, it is really hard to do 🙂erictraut commentedon Jan 9, 2022
This is yet another case where mypy's choice to use join rather than union causes problems. Pyright uses only unions, never joins, so it produces the expected result in this case.
Has there been any serious discussion of changing mypy's behavior to use unions instead of joins? I can't think of any case where joins are preferable, and there are many cases where unions are better because they retain more detailed type information.
sobolevn commentedon Jan 9, 2022
CC @JukkaL
AlexWaygood commentedon Mar 29, 2022
Closing as a duplicate of #8586