Advertisement
Guest User

Untitled

a guest
May 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. from typing import TypeVar, Callable, Tuple, overload, Any
  2.  
  3. T1 = TypeVar('T1')
  4. T2 = TypeVar('T2')
  5. T3 = TypeVar('T3')
  6. R = TypeVar('R')
  7.  
  8. @overload
  9. def f(c: Callable[[T1], R], A: Tuple[T1]) -> R: ...
  10.  
  11. @overload
  12. def f(c: Callable[[T1, T2], R], A: Tuple[T1, T2]) -> R: ...
  13.  
  14. @overload
  15. def f(c: Callable[[T1, T2, T3], R], A: Tuple[T1, T2, T3]) -> R: ...
  16.  
  17.  
  18. def f(c, a):
  19. return c(*a)
  20.  
  21.  
  22. def t1(a: int) -> None:
  23. pass
  24.  
  25.  
  26. def t2(a: str, b: int) -> None:
  27. pass
  28.  
  29.  
  30. def t3(a: int, b: int) -> None:
  31. pass
  32.  
  33.  
  34. f(t1, ('2',))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement