Most
asyncioscheduling functions don’t allow passing keyword arguments. To do that, usefunctools.partial()
I’d like to be able to type annotate these scheduling methods like run_in_executor, call_soon with ParamSpec, however because they do not take kwargs it’s not possible:
see: mypy Playground
adding support for kwargs via positional-only parameters allows ParamSpec to work:
mypy Playground however it would be a breaking change when passing executor and func as kwargs and no other args:
>>> await asyncio.get_running_loop().run_in_executor(executor=None, func=sync_fn)
an additional caveat is that this would also have to change how Context is passed to these callbacks, eg: mypy Playground