0

Consider the following function:

def test(data: np.ndarray, func, *args) -> np.ndarray:
    return func(data, args)

The func and args arguments are numpy function and arguments corresponding to it. The question is, how do i annotate these two arguments with type hinting?

DHJ
  • 611
  • 2
  • 13
  • See also: https://stackoverflow.com/questions/37031928/type-annotations-for-args-and-kwargs – gvee Sep 27 '22 at 09:58

1 Answers1

2

typing.Callable springs to mind for the func argument.

As for *args - whilst it can be type hinted, I'd question the value of doing so. After all, it's an arbitrary set of positional arguments.

However, if you insist on doing so, then *args is of type typing.Tuple

gvee
  • 16,732
  • 35
  • 50