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
Feature
I wish mypy understood that following code is actually correct:
deffoo(x: tuple[str, str] |tuple[str, str, str]):
iflen(x) ==2:
obs, info=x# error: Too many values to unpack (2 expected, 3 provided) [misc]
...
Pitch
Tuples are universal way to return multiple values in python, and are ubiquitous. It's natural to process cases where data can come in different number of elements with length checks. Currently I could write a custom type guard function (is boilerplate and extra effort) or # type: ignore (but I lose benefit of type checking here)
pyright understands this case, and I wish mypy did as well.
The text was updated successfully, but these errors were encountered:
Feature
I wish mypy understood that following code is actually correct:
Pitch
Tuples are universal way to return multiple values in python, and are ubiquitous. It's natural to process cases where data can come in different number of elements with length checks. Currently I could write a custom type guard function (is boilerplate and extra effort) or # type: ignore (but I lose benefit of type checking here)
pyright
understands this case, and I wish mypy did as well.The text was updated successfully, but these errors were encountered: