From 21705a3f9c28b0890365ac0ff20922d5b067f630 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 15 May 2025 13:15:24 -0400 Subject: [PATCH 1/3] Reflect deprecation for `asyncio.iscoroutinefunction` Co-authored-by: Peter Bierma --- stdlib/asyncio/coroutines.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stdlib/asyncio/coroutines.pyi b/stdlib/asyncio/coroutines.pyi index 8ef30b3d3198..07366b5b204b 100644 --- a/stdlib/asyncio/coroutines.pyi +++ b/stdlib/asyncio/coroutines.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Awaitable, Callable, Coroutine from typing import Any, TypeVar, overload -from typing_extensions import ParamSpec, TypeGuard, TypeIs +from typing_extensions import ParamSpec, TypeGuard, TypeIs, deprecated # Keep asyncio.__all__ updated with any changes to __all__ here if sys.version_info >= (3, 11): @@ -17,11 +17,15 @@ if sys.version_info < (3, 11): def coroutine(func: _FunctionT) -> _FunctionT: ... @overload +@deprecated("Use inspect.iscoroutinefunction instead") def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ... @overload +@deprecated("Use inspect.iscoroutinefunction instead") def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ... @overload +@deprecated("Use inspect.iscoroutinefunction instead") def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ... @overload +@deprecated("Use inspect.iscoroutinefunction instead") def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ... def iscoroutine(obj: object) -> TypeIs[Coroutine[Any, Any, Any]]: ... From 5cccdfa57c1b0a519d863e4f845b235c1775fb41 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 15 May 2025 13:21:49 -0400 Subject: [PATCH 2/3] Move check_coroutines test from asyncio to inspect --- .../@tests/test_cases/{asyncio => inspect}/check_coroutines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename stdlib/@tests/test_cases/{asyncio => inspect}/check_coroutines.py (95%) diff --git a/stdlib/@tests/test_cases/asyncio/check_coroutines.py b/stdlib/@tests/test_cases/inspect/check_coroutines.py similarity index 95% rename from stdlib/@tests/test_cases/asyncio/check_coroutines.py rename to stdlib/@tests/test_cases/inspect/check_coroutines.py index 160bd896469e..f68cc3cfa76b 100644 --- a/stdlib/@tests/test_cases/asyncio/check_coroutines.py +++ b/stdlib/@tests/test_cases/inspect/check_coroutines.py @@ -1,6 +1,6 @@ from __future__ import annotations -from asyncio import iscoroutinefunction +from inspect import iscoroutinefunction from collections.abc import Awaitable, Callable, Coroutine from typing import Any from typing_extensions import assert_type From 19f27ef728699c031e00a198d4f7b32ca91de45a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 17:23:37 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/@tests/test_cases/inspect/check_coroutines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/@tests/test_cases/inspect/check_coroutines.py b/stdlib/@tests/test_cases/inspect/check_coroutines.py index f68cc3cfa76b..f331c15cb081 100644 --- a/stdlib/@tests/test_cases/inspect/check_coroutines.py +++ b/stdlib/@tests/test_cases/inspect/check_coroutines.py @@ -1,7 +1,7 @@ from __future__ import annotations -from inspect import iscoroutinefunction from collections.abc import Awaitable, Callable, Coroutine +from inspect import iscoroutinefunction from typing import Any from typing_extensions import assert_type