Stefan Behnel added the comment:

> 1. abc.Coroutine and abc.Awaitable will guarantee that objects that implement 
> them have '__await__' and it's safe to access it (that means that they will 
> fail for generator-based coroutines).

Absolutely. That was the main theme behind the whole type split.

> 2. inspect.isgenerator() can be used along with inspect.isawaitable() to 
> detect generator-based coroutines (generators with CO_ITERABLE_COROUTINE 
> flag).

I still don't like the idea of having an inspect.isawaitable() that only
checks for an ABC. If you want an ABC test, say it in your code. If you
want to test for an "__await__" attribute, say it. A helper function
inspect.isawaitable() suggests that there is some (builtin) type to inspect
here, not a protocol. ABCs are about abstract protocols, inspect is about
concrete types.

If you want to cover the "iterable coroutine" case, why not add an inspect
helper function for that? That's clearly a concrete type (even more
concrete than a concrete type) that can be inspected.

----------

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

Reply via email to