Skip to content

Instantly share code, notes, and snippets.

@hackaugusto
Created May 9, 2019 14:43
Show Gist options
  • Select an option

  • Save hackaugusto/67658a0ee1e59d97ce40f81085ed3116 to your computer and use it in GitHub Desktop.

Select an option

Save hackaugusto/67658a0ee1e59d97ce40f81085ed3116 to your computer and use it in GitHub Desktop.
from typing import TypeVar, Callable, Tuple, overload, Any
T1 = TypeVar('T1')
T2 = TypeVar('T2')
T3 = TypeVar('T3')
R = TypeVar('R')
@overload
def f(c: Callable[[T1], R], A: Tuple[T1]) -> R: ...
@overload
def f(c: Callable[[T1, T2], R], A: Tuple[T1, T2]) -> R: ...
@overload
def f(c: Callable[[T1, T2, T3], R], A: Tuple[T1, T2, T3]) -> R: ...
def f(c, a):
return c(*a)
def t1(a: int) -> None:
pass
def t2(a: str, b: int) -> None:
pass
def t3(a: int, b: int) -> None:
pass
f(t1, ('2',))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment