Closed
Description
I am using Python 3.6.4 and the latest version of Mypy from master (mypy 0.570-dev-3545a71ba11576b08007f70d8407bf7924738886).
I have a file with the following code:
from typing import TypeVar
T = TypeVar('T', int, str)
def foo() -> T:
return 1
If I run it through Mypy, I get this error: typevar_test.py:6: error: Incompatible return value type (got "int", expected "str")
.
If I make the function return a string, I get a similar error: typevar_test.py:6: error: Incompatible return value type (got "str", expected "int")
.
If I make the function return something not specified by the TypeVar (such as a list, for example), I get two errors:
typevar_test.py:6: error: Incompatible return value type (got "List[int]", expected "int")
typevar_test.py:6: error: Incompatible return value type (got "List[int]", expected "str")
Metadata
Metadata
Assignees
Labels
No labels