Skip to content

Commit 8c6429e

Browse files
committed
Adjust iscoroutinefunction() to look for async __call__.
1 parent ab422f7 commit 8c6429e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/inspect.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,9 @@ def iscoroutinefunction(obj):
396396
397397
Coroutine functions are defined with "async def" syntax.
398398
"""
399-
return _has_code_flag(obj, CO_COROUTINE)
399+
return _has_code_flag(obj, CO_COROUTINE) or (
400+
callable(obj) and _has_code_flag(obj.__call__, CO_COROUTINE)
401+
)
400402

401403
def isasyncgenfunction(obj):
402404
"""Return true if the object is an asynchronous generator function.

0 commit comments

Comments
 (0)