Stefan Behnel <stefan...@behnel.de> added the comment:

My usual first reaction is: "if you need to find out whether the return value 
of a callable will be an Awaitable or not, without calling it, then you're 
probably doing something wrong in your design".

However,
a) there is code that tries this already (and it falls short in various ways 
while trying)
b) asyncio has a function `iscoroutinefunction` which *seems* to fulfil this 
need but does not achieve it (because not everything that returns an Awaitable 
is a "coroutine function")
c) asyncio has an internal protocol for marking things as "is a coroutine", 
which comes close to but isn't "returns an Awaitable when called"

So – should there be an official protocol for marking callables as returning an 
Awaitable? Should we look at annotations for that? Anything else? Or do we 
consider this intention inherently flawed?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38225>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to