Suppose I have a function that takes in a function and produces a new function that calls the original function twice with two different sets of inputs:
def duplicate(f):
def g(args1, args2):
return (f(*args1), f(*args2))
return g
Is there a way to provide type annotations for this function so that mypy will be able to infer the signature of g based upon f? In particular, if I supplied:
def f(a: int, b: str):
...
and produced:
g = duplicate(f)
I'd like it to be able to be inferred that the signature of g is (int, str, int, str) -> ... but I'm not aware of how to accomplish this.
Any help appreciated :)