gh-122858: Deprecate asyncio.iscoroutinefunction (#122875)

Deprecate `asyncio.iscoroutinefunction` in favor of `inspect.iscoroutinefunction`.

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
Wulian 2024-08-12 00:35:51 +08:00 committed by GitHub
parent 3aaed083a3
commit bc9d92c679
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 27 additions and 8 deletions

View file

@ -18,7 +18,16 @@ _is_coroutine = object()
def iscoroutinefunction(func):
import warnings
"""Return True if func is a decorated coroutine function."""
warnings._deprecated("asyncio.iscoroutinefunction",
f"{warnings._DEPRECATED_MSG}; "
"use inspect.iscoroutinefunction() instead",
remove=(3,16))
return _iscoroutinefunction(func)
def _iscoroutinefunction(func):
return (inspect.iscoroutinefunction(func) or
getattr(func, '_is_coroutine', None) is _is_coroutine)