T = TypeVar("T", bound=str)
def foo(a: T, b: T) -> T:
return a + b
print(foo("1", "2"))
mypy:
error: Incompatible return value type (got "str", expected "T") [return-value]
I dont understand how to fix this problem(using bound).
T: return a + b print(foo("1", "2")) mypy: error: Incompatible return value type (got "str", expect" /> T: return a + b print(foo("1", "2")) mypy: error: Incompatible return value type (got "str", expect" /> T: return a + b print(foo("1", "2")) mypy: error: Incompatible return value type (got "str", expect"/>
T = TypeVar("T", bound=str)
def foo(a: T, b: T) -> T:
return a + b
print(foo("1", "2"))
mypy:
error: Incompatible return value type (got "str", expected "T") [return-value]
I dont understand how to fix this problem(using bound).
Copyright © 2021 Jogjafile Inc.