-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Don't truncate Tuple, Union, and generic types in error messages #287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@JukkaL $ mypy z.py
z.py, line 2: List item 1 has incompatible type "Tuple[str, str, List[str], int]" |
There's some logic to avoid printing out really long types. 655eddf#diff-7739b07c7ae4561e51cbb36f31984c90L188 increased the limit, but you can still reach the limit by adding a couple more fields to the tuple. Personally I would prefer always seeing the full type; the details might matter to the message (like here, with |
Yeah, I've encountered a few cases where the truncated message ended up being pure misdirection. |
I've been bitten by this as well. In retrospect, truncating long types now seems like a bad idea in general. It might still be occasionally useful in cases like There are other options such as run length encoding long tuples (for example, Another option for cases where we display an expected and an actual type would be to run a more complete type diff algorithm and highlight the differences (e.g.,
By aligning the types it would be easier to see how they are different in case they are similar but not compatible. |
Current status: when the full, untruncated rendering of the type is over 40 characters, we abbreviate it to look like |
This is something that would/should be fixed as part of #1582, if it's not fixed sooner. |
I expanded the scope of this issue slightly in its title. The same A nice follow-up would be to present a diff like @JukkaL suggests in a comment above, but that should come separately after making the simpler change to stop truncating. |
For unions I just upped the truncation limit from 40 to 400. That should cover most cases. f67bdbd |
This increases the length limits for Tuple and TypeVar to 400 and 150, respectively (from 40 and 25). Fixes #287.
This gives the expected error::
Error::
But this shortens the type to just 'tuple'::
Error::
The text was updated successfully, but these errors were encountered: