summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/inspect.rst25
1 files changed, 23 insertions, 2 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index 6705577..58b84a3 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -343,8 +343,10 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
.. function:: iscoroutinefunction(object)
- Return ``True`` if the object is a :term:`coroutine function`
- (a function defined with an :keyword:`async def` syntax).
+ Return ``True`` if the object is a :term:`coroutine function` (a function
+ defined with an :keyword:`async def` syntax), a :func:`functools.partial`
+ wrapping a :term:`coroutine function`, or a sync function marked with
+ :func:`markcoroutinefunction`.
.. versionadded:: 3.5
@@ -352,6 +354,25 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
Functions wrapped in :func:`functools.partial` now return ``True`` if the
wrapped function is a :term:`coroutine function`.
+ .. versionchanged:: 3.12
+ Sync functions marked with :func:`markcoroutinefunction` now return
+ ``True``.
+
+
+.. function:: markcoroutinefunction(func)
+
+ Decorator to mark a callable as a :term:`coroutine function` if it would not
+ otherwise be detected by :func:`iscoroutinefunction`.
+
+ This may be of use for sync functions that return a :term:`coroutine`, if
+ the function is passed to an API that requires :func:`iscoroutinefunction`.
+
+ When possible, using an :keyword:`async def` function is preferred. Also
+ acceptable is calling the function and testing the return with
+ :func:`iscoroutine`.
+
+ .. versionadded:: 3.12
+
.. function:: iscoroutine(object)