The documentation states that "This method is different from inspect.iscoroutine() because it returns True for generator-based coroutines decorated with @coroutine." It seems to be wrong, a method written as follow: def test(): yield 1 will be evaluated as a coroutine by asyncio.iscoroutine(), even if not decorated. The old doc stated "Return True if obj is a coroutine object, which may be based on a generator or an async def coroutine.", which seems more correct.
Thanks for the report. I believe this was done as part asyncio docs overhaul and I am adding Yury here. The current docs link to #coroutine from asyncio.iscoroutine whereas the previous docs had the definition inline. I think this is clarified in #awaitables section but takes a round-trip and it's not in #coroutines section which is linked in asyncio.iscoroutine. The below is present in important note in #awaitables and may be this can be added to #coroutine too so that it's not last? Suggestions welcome > asyncio also supports legacy generator-based coroutines I would suggest below for #coroutines : > Coroutines declared with async/await syntax is the preferred way of writing asyncio applications but asyncio also supports legacy generator-based coroutines. Thanks
I'll make a simple fix for the asyncio.coroutine decorator docs. > I would suggest below for #coroutines : >> Coroutines declared with async/await syntax is the preferred way of writing asyncio applications but asyncio also supports legacy generator-based coroutines. I don't want to further emphasize generator-based coroutines beyond how they are covered right now. We'll drop support for them in a just a couple of versions anyways.