-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
This program genenerates an unhelpful error message:
from typing import Tuple
t: Tuple[int, ...] = (
1, 2, 3, 4, 5, 6, 7, 8, 9., 10, 11, 12, 13, 14, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
3, 31, 32, 33, 34, 35, 36, 37, 3, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 4, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
30, 31, 32, 33, 34, 234234, 36, 37, 38, 39, 40, 1, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
57, 58, 59, 60, 61, 62, 63
)
This is the message:
t.py:3: error: Incompatible types in assignment (expression has type <tuple: 148 items>, variable has type "Tuple[int, ...]")
This is derived from a real example, where the type was Tuple[Type[x], ...]
and the initializer contained a long tuple of type objects. Figuring out which type object is incompatible was tricky.
Some ideas about how to improve this:
- Point to individual tuple items that are incompatible. For example:
Tuple item 8 has type "float"; "int" expected
(also point the error message to the relevant line/column). - If there are many incompatibilities, only show a fixed number of them and hide the remaining ones.