Skip to content

Commit

Permalink
Adjust iscoroutinefunction() to look for async __call__.
Browse files Browse the repository at this point in the history
  • Loading branch information
carltongibson committed Nov 15, 2022
1 parent ab422f7 commit 8c6429e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@ def iscoroutinefunction(obj):
Coroutine functions are defined with "async def" syntax.
"""
return _has_code_flag(obj, CO_COROUTINE)
return _has_code_flag(obj, CO_COROUTINE) or (
callable(obj) and _has_code_flag(obj.__call__, CO_COROUTINE)
)

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

0 comments on commit 8c6429e

Please sign in to comment.