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
Unfortunately, the first example is too difficult for mypy to figure out. For example, mypy would have to understand that a mismatch in tuple lengths results in ValueError, but mypy doesn't have any knowledge of which exceptions may be raised by various operations.
However, a if len(...) == x check to narrow narrow down the union would be feasible (tracked in #1178).
I am reporting a bug.
The type checker should report no error.
mypy==0.750+dev.8ada8e2cdb5432d41f188d2d0610ce21a2c62c12
Python 3.7.3
mypy --strict
The call site looks good
I also tried to replace the
try-except
with anif len(...) == 2
but that didn't change the error at all.Currently, i use this workaround
But this is not ideal, because, the first version will actually throw a
ValueError
during runtime iif more than 4 elements are in the tuple.The text was updated successfully, but these errors were encountered: