79391067

Date: 2025-01-27 14:11:23
Score: 1
Natty:
Report link

Thanks to @Daraan, I was able to figure out how to do this by wrapping TypeVarTuple inside a Tuple:

from typing import TypeVar, Callable, Tuple
from typing_extensions import TypeVarTuple

T = TypeVar('T')
Ts = TypeVarTuple('Ts')

def apply(fn: Callable[[*Ts], T], vals: Tuple[*Ts]) -> T:
    return fn(*vals)
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Low length (0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Daraan
  • Self-answer (0.5):
  • High reputation (-1):
Posted by: Jan Spurny