docs/inspect: clarify iscoroutinefunction; add docs for isasyncgen*
This commit is contained in:
parent
0180cf6684
commit
4778e13148
|
@ -179,17 +179,22 @@ def isgeneratorfunction(object):
|
||||||
def iscoroutinefunction(object):
|
def iscoroutinefunction(object):
|
||||||
"""Return true if the object is a coroutine function.
|
"""Return true if the object is a coroutine function.
|
||||||
|
|
||||||
Coroutine functions are defined with "async def" syntax,
|
Coroutine functions are defined with "async def" syntax.
|
||||||
or generators decorated with "types.coroutine".
|
|
||||||
"""
|
"""
|
||||||
return bool((isfunction(object) or ismethod(object)) and
|
return bool((isfunction(object) or ismethod(object)) and
|
||||||
object.__code__.co_flags & CO_COROUTINE)
|
object.__code__.co_flags & CO_COROUTINE)
|
||||||
|
|
||||||
def isasyncgenfunction(object):
|
def isasyncgenfunction(object):
|
||||||
|
"""Return true if the object is an asynchronous generator function.
|
||||||
|
|
||||||
|
Asynchronous generator functions are defined with "async def"
|
||||||
|
syntax and have "yield" expressions in their body.
|
||||||
|
"""
|
||||||
return bool((isfunction(object) or ismethod(object)) and
|
return bool((isfunction(object) or ismethod(object)) and
|
||||||
object.__code__.co_flags & CO_ASYNC_GENERATOR)
|
object.__code__.co_flags & CO_ASYNC_GENERATOR)
|
||||||
|
|
||||||
def isasyncgen(object):
|
def isasyncgen(object):
|
||||||
|
"""Return true if the object is an asynchronous generator."""
|
||||||
return isinstance(object, types.AsyncGeneratorType)
|
return isinstance(object, types.AsyncGeneratorType)
|
||||||
|
|
||||||
def isgenerator(object):
|
def isgenerator(object):
|
||||||
|
|
Loading…
Reference in New Issue