I have a lot of functions that have the same signature, let's say (int, int) -> int
.
Is there a way to type these functions with a Callable
(or something else) to avoid specifying the types of the parameters and the return type for each of these functions? I would like to do something like that (but it obviously fails):
from typing import Callable
f: Callable[[int, int], int]
def f(x, y): # with the previous line, this is equivalent to 'def f(x: int, y: int) -> int:'
...
Running mypy results in:
file.py:4: error: Name "f" already defined on line 3
Found 1 error in 1 file (checked 1 source file)