@@ -348,26 +348,30 @@ attributes:
348
348
349
349
.. function :: iscoroutinefunction(object)
350
350
351
- Return ``True `` if the object is a :term: `coroutine function `
352
- (a function defined with an :keyword: `async def ` syntax).
351
+ Return ``True `` if the object is a :term: `coroutine function ` (a function
352
+ defined with an :keyword: `async def ` syntax), a :func: `functools.partial `
353
+ wrapping a :term: `coroutine function` `, or an instance of a class defining
354
+ an :keyword: `async def ` ``__call__ ``.
353
355
354
356
.. versionadded :: 3.5
355
357
356
358
.. versionchanged :: 3.8
357
359
Functions wrapped in :func: `functools.partial ` now return ``True `` if the
358
360
wrapped function is a :term: `coroutine function `.
359
361
362
+ .. versionchanged :: 3.12
363
+ Instances of classes defining an :keyword: `async def ` ``__call__ `` now
364
+ return ``True ``.
365
+
360
366
361
367
.. function :: markcoroutinefunction(func)
362
368
363
369
Decorator to mark a callable as a :term: `coroutine function ` if it would not
364
370
otherwise be detected by :func: `iscoroutinefunction `.
365
371
366
- This may be of use for sync functions that return an awaitable or objects
367
- implementing an :keyword: `async def ` ``__call__ ``.
368
-
369
- Prefer :keyword: `async def ` functions or calling the function and testing
370
- the return with :func: `isawaitable ` where feasible.
372
+ This may be of use for sync functions that return a :term: `coroutine `, but
373
+ prefer :keyword: `async def ` functions, or if necessary calling the function
374
+ and testing the return with :func: `iscoroutine ` where feasible.
371
375
372
376
.. versionadded :: 3.12
373
377
0 commit comments