false negative on tuple with incorrect length when instantiated with `tuple`
foo = tuple[int, int]((1, 2, 3)) # no error
boo: tuple[int, int] = (1, 2, 3) # error: Incompatible types in assignment (expression has type "Tuple[int, ...]", variable has type "Tuple[int, int]") [assignment]
This is because of the way the tuple constructor is defined in typeshed. A static type checker would need to override the typeshed definition and provide special-case logic to catch the above issue. That's perhaps a reasonable feature request, but I don't think the current behavior is a bug.
current master (10f18a82b612b6127659cd64aa60c10b9cc7a904) gives: /home/xju/tmp/xxx.py:1:23: error: Argument 1 to "tuple" has incompatible type "tuple[int, int, int]"; expected "tuple[int, int]" [arg-type] /home/xju/tmp/xxx.py:2:24: error: Incompatible types in assignment (expression has type "tuple[int, int, int]", variable has type "tuple[int, int]") [assignment] Found 2 errors in 1 file (checked 1 source file)
... is that what we need in this case?
Looks like this was fixed in 6c24ea66e20166964aa5d42e28fda5b4b69f44b1 (#17235), released with v1.11.0