Remove use of `asyncio.coroutines.iscoroutinefunction()` (#769)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e1497e..47af48c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml
@@ -100,7 +100,7 @@ cd src python --version # just to make sure we're running the right one # Run tests under coverage - python -m coverage run -m unittest test_typing_extensions.py + python -We -m coverage run -m unittest test_typing_extensions.py # Create xml file for Codecov coverage xml --rcfile=../pyproject.toml --fail-under=0
diff --git a/CHANGELOG.md b/CHANGELOG.md index 23abcb3..a87dfbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md
@@ -1,3 +1,8 @@ +# Unreleased + +- Avoid a `DeprecationWarning` when applying `deprecated` to a coroutine function on + Python 3.14.0. + # Release 4.16.0rc1 (June 24, 2026) - Make `typing_extensions.TypeAliasType`'s `__module__` attribute writable.
diff --git a/src/typing_extensions.py b/src/typing_extensions.py index f95c0bc..ced7837 100644 --- a/src/typing_extensions.py +++ b/src/typing_extensions.py
@@ -3131,7 +3131,6 @@ __init_subclass__.__deprecated__ = msg return arg elif callable(arg): - import asyncio.coroutines import functools import inspect @@ -3140,11 +3139,13 @@ warnings.warn(msg, category=category, stacklevel=stacklevel + 1) return arg(*args, **kwargs) - if asyncio.coroutines.iscoroutinefunction(arg): + if inspect.iscoroutinefunction(arg): # Breakpoint: https://github.com/python/cpython/pull/99247 if sys.version_info >= (3, 12): wrapper = inspect.markcoroutinefunction(wrapper) else: + import asyncio.coroutines + wrapper._is_coroutine = asyncio.coroutines._is_coroutine arg.__deprecated__ = wrapper.__deprecated__ = msg