mypy doesn’t get error with the generic function which has multiple constrained types as shown below:
# ↓↓↓ ↓↓↓↓↓
def func[T: (int, float)](num: T) -> T:
return num * 3
But mypy gets the error with the generic function which has a single constrained type as shown below:
# ↓↓↓
def func[T: (int,)](num: T) -> T:
return num * 3
error: Type variable must have at least two constrained types
So using mypy, why does a generic function need at least two constrained types?