What’s the difference between a constrained TypeVar and a Union?
T‘s type must be consistent across multiple uses within a given scope, while U‘s does not. With a Union type used as function parameters, the arguments as well as the return type can all be different: U = Union[int, str] def union_f(arg1: U, arg2: U) -> U: return arg1 x = union_f(1, “b”) # No … Read more