Idenity Type
julien-blanchon opened this issue · 2 comments
julien-blanchon commented
I'm trying to type such functions:
def identity[T](*args: T) -> T:
# Modify the arguments in some way but keep the same type
...
new_args = args
# Return the modified arguments
return new_args
I would like to be able to have such behaviour:
new_a, new_b, new_c = identity(a, b, c)
With a, b and c of type different A, B, C
JelleZijlstra commented
This is already possible:
def identity[*Ts](*args: *Ts) -> tuple[*Ts]:
return args
julien-blanchon commented
Waw this is great ! Thanks a lot