You are looking for:
FuncType = Callable[[Any, Any], Awaitable[Any]]
def consumer(function_: FuncType = None):
pass # TODO: do stuff
Why is the type structured like that? If you declare a function async
, what you actually do is wrap it in a new function with the given parameters, which returns a Coroutine
.
Since this might be relevant to some people who come here, this is an example of an await
able function type with in and out typed:
OnAction = Callable[[Foo, Bar], Awaitable[FooBar]]
It is a function that takes Foo
, Bar
and returns a FooBar