mypy=0.800
python=3.8.6
The following code generates
error: Incompatible return value type (got "str", expected "Union[ndarray, T]")
from __future__ importannotationsfromtypingimportTypeVar, UnionimportnumpyT=TypeVar("T")
def_test(a: list[T]) ->Union[numpy.ndarray, T]:
ifisinstance(a[0], str):
returna[0]
returnnumpy.array(a)
mypy=0.800
python=3.8.6
The following code generates
error: Incompatible return value type (got "str", expected "Union[ndarray, T]")