Skip to content

Commit 2f3cdda

Browse files
committed
Remove use of asyncio.coroutines.iscoroutinefunction()
1 parent 224f8d5 commit 2f3cdda

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
@@ -83,7 +83,7 @@ jobs:
8383
cd src
8484
python --version # just to make sure we're running the right one
8585
# Run tests under coverage
86-
python -m coverage run -m unittest test_typing_extensions.py
86+
python -We -m coverage run -m unittest test_typing_extensions.py
8787
# Create xml file for Codecov
8888
coverage xml --rcfile=../pyproject.toml --fail-under=0
8989

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
@@ -3130,7 +3130,6 @@ def __init_subclass__(cls, *args, **kwargs):
31303130
__init_subclass__.__deprecated__ = msg
31313131
return arg
31323132
elif callable(arg):
3133-
import asyncio.coroutines
31343133
import functools
31353134
import inspect
31363135

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

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

31493150
arg.__deprecated__ = wrapper.__deprecated__ = msg

0 commit comments

Comments
 (0)