Search code examples
pythonmypy

Mypy type of concatenate tuples


I have a function that takes specific tuples and concatenates and I am trying to specify the type of the output but mypy does not agree with me.

File test.py:

from typing import Tuple

def test(a: Tuple[str, str], b: Tuple[int, int]) -> Tuple[str, str, int, int]:
    return a + b

running mypy 0.641 as mypy --ignore-missing-imports test.py I get:

test.py:5: error: Incompatible return value type (got "Tuple[Any, ...]", expected "Tuple[str, str, int, int]")

Which i guess is true but more generic, given that I specify my inputs.


Solution

  • This is was a known issue, but there appears to be no timeline for enabling mypywas fixed later in 2019 to do the correct type inference.