-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
This is a feature request.
from typing import Tuple
def test_1(inp1: Tuple[int, int, int]) -> None:
pass
def test_2(inp2: Tuple[int, int, int]) -> None:
test_tuple = tuple(e for e in inp2)
reveal_type(test_tuple)
test_1(test_tuple)
The code above, when run with mypy 0.590
(no flags) and Python 3.6, results in:
mypytest.py:7: error: Revealed type is 'builtins.tuple[builtins.int*]'
mypytest.py:8: error: Argument 1 to "test_1" has incompatible type "Tuple[int, ...]"; expected "Tuple[int, int, int]"
I appreciate that the types inside a list comprehension are not trivial to infer, but maybe mypy
could at least handle a case where there are no operations on the elements, and I'm looping through all elements, as shown above? The expected type of test_tuple
would then be builtins.tuple[builtins.int, builtins.int, builtins.int]
.
benjaminsaljooghi, amcgregor, svalentin, frederikaalund, abey79 and 6 more