Skip to content

Commit 37ed08a

Browse files
authored
Remove use of asyncio.coroutines.iscoroutinefunction() (#769)
1 parent 8dcc559 commit 37ed08a

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
cd src
101101
python --version # just to make sure we're running the right one
102102
# Run tests under coverage
103-
python -m coverage run -m unittest test_typing_extensions.py
103+
python -We -m coverage run -m unittest test_typing_extensions.py
104104
# Create xml file for Codecov
105105
coverage xml --rcfile=../pyproject.toml --fail-under=0
106106

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Unreleased
2+
3+
- Avoid a `DeprecationWarning` when applying `deprecated` to a coroutine function on
4+
Python 3.14.0.
5+
16
# Release 4.16.0rc1 (June 24, 2026)
27

38
- Make `typing_extensions.TypeAliasType`'s `__module__` attribute writable.

‎src/typing_extensions.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3131,7 +3131,6 @@ def __init_subclass__(cls, *args, **kwargs):
31313131
__init_subclass__.__deprecated__ = msg
31323132
return arg
31333133
elif callable(arg):
3134-
import asyncio.coroutines
31353134
import functools
31363135
import inspect
31373136

@@ -3140,11 +3139,13 @@ def wrapper(*args, **kwargs):
31403139
warnings.warn(msg, category=category, stacklevel=stacklevel + 1)
31413140
return arg(*args, **kwargs)
31423141

3143-
if asyncio.coroutines.iscoroutinefunction(arg):
3142+
if inspect.iscoroutinefunction(arg):
31443143
# Breakpoint: https://github.com/python/cpython/pull/99247
31453144
if sys.version_info >= (3, 12):
31463145
wrapper = inspect.markcoroutinefunction(wrapper)
31473146
else:
3147+
import asyncio.coroutines
3148+
31483149
wrapper._is_coroutine = asyncio.coroutines._is_coroutine
31493150

31503151
arg.__deprecated__ = wrapper.__deprecated__ = msg

0 commit comments

Comments
 (0)