From d3b5ad9ff51e5ab11ef9c194026499eb3c88a7d1 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Sat, 20 Jun 2026 08:33:26 -0700 Subject: [PATCH 1/5] Make TypeIs Signed-off-by: Michael Carlstrom --- stdlib/asyncio/coroutines.pyi | 12 ++++++------ stdlib/inspect.pyi | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/stdlib/asyncio/coroutines.pyi b/stdlib/asyncio/coroutines.pyi index 7599c692949b..b40f16e027c7 100644 --- a/stdlib/asyncio/coroutines.pyi +++ b/stdlib/asyncio/coroutines.pyi @@ -25,21 +25,21 @@ if sys.version_info >= (3, 11): def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ... @overload @deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.") - def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ... + def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeIs[Callable[_P, Coroutine[Any, Any, _T]]]: ... @overload @deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.") - def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ... + def iscoroutinefunction(func: Callable[_P, object]) -> TypeIs[Callable[_P, Coroutine[Any, Any, Any]]]: ... @overload @deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.") - def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ... + def iscoroutinefunction(func: object) -> TypeIs[Callable[..., Coroutine[Any, Any, Any]]]: ... else: # Sometimes needed in Python < 3.11 due to the fact that it supports @coroutine # which was removed in 3.11 which the inspect version doesn't support. @overload def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ... @overload - def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ... + def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeIs[Callable[_P, Coroutine[Any, Any, _T]]]: ... @overload - def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ... + def iscoroutinefunction(func: Callable[_P, object]) -> TypeIs[Callable[_P, Coroutine[Any, Any, Any]]]: ... @overload - def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ... + def iscoroutinefunction(func: object) -> TypeIs[Callable[..., Coroutine[Any, Any, Any]]]: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index 387540c659ba..657d93cdab99 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -239,11 +239,11 @@ def isgeneratorfunction(obj: object) -> TypeGuard[Callable[..., GeneratorType[An @overload def iscoroutinefunction(obj: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ... @overload -def iscoroutinefunction(obj: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, CoroutineType[Any, Any, _T]]]: ... +def iscoroutinefunction(obj: Callable[_P, Awaitable[_T]]) -> TypeIs[Callable[_P, CoroutineType[Any, Any, _T]]]: ... @overload -def iscoroutinefunction(obj: Callable[_P, object]) -> TypeGuard[Callable[_P, CoroutineType[Any, Any, Any]]]: ... +def iscoroutinefunction(obj: Callable[_P, object]) -> TypeIs[Callable[_P, CoroutineType[Any, Any, Any]]]: ... @overload -def iscoroutinefunction(obj: object) -> TypeGuard[Callable[..., CoroutineType[Any, Any, Any]]]: ... +def iscoroutinefunction(obj: object) -> TypeIs[Callable[..., CoroutineType[Any, Any, Any]]]: ... def isgenerator(object: object) -> TypeIs[GeneratorType[Any, Any, Any]]: ... def iscoroutine(object: object) -> TypeIs[CoroutineType[Any, Any, Any]]: ... From 4147a3e144ba8f01ba0abd94e3be26a7f79f0f37 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 20 Jun 2026 15:36:05 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/asyncio/coroutines.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/asyncio/coroutines.pyi b/stdlib/asyncio/coroutines.pyi index b40f16e027c7..a285974adec4 100644 --- a/stdlib/asyncio/coroutines.pyi +++ b/stdlib/asyncio/coroutines.pyi @@ -1,6 +1,6 @@ import sys from collections.abc import Awaitable, Callable, Coroutine -from typing import Any, ParamSpec, TypeGuard, TypeVar, overload +from typing import Any, ParamSpec, TypeVar, overload from typing_extensions import TypeIs, deprecated # Keep asyncio.__all__ updated with any changes to __all__ here From 05ecac150bf4054e7eb9f23f76646c7bd5bcabd9 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Sat, 20 Jun 2026 08:36:09 -0700 Subject: [PATCH 3/5] Remove unused import Signed-off-by: Michael Carlstrom --- stdlib/asyncio/coroutines.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/asyncio/coroutines.pyi b/stdlib/asyncio/coroutines.pyi index b40f16e027c7..a285974adec4 100644 --- a/stdlib/asyncio/coroutines.pyi +++ b/stdlib/asyncio/coroutines.pyi @@ -1,6 +1,6 @@ import sys from collections.abc import Awaitable, Callable, Coroutine -from typing import Any, ParamSpec, TypeGuard, TypeVar, overload +from typing import Any, ParamSpec, TypeVar, overload from typing_extensions import TypeIs, deprecated # Keep asyncio.__all__ updated with any changes to __all__ here From aa30a760345b1117166b155de9bca545d1c493c0 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Sat, 20 Jun 2026 08:44:35 -0700 Subject: [PATCH 4/5] Update test Signed-off-by: Michael Carlstrom --- stdlib/@tests/test_cases/asyncio/check_coroutines.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/@tests/test_cases/asyncio/check_coroutines.py b/stdlib/@tests/test_cases/asyncio/check_coroutines.py index 6062ca55146a..10fe854073f1 100644 --- a/stdlib/@tests/test_cases/asyncio/check_coroutines.py +++ b/stdlib/@tests/test_cases/asyncio/check_coroutines.py @@ -19,10 +19,10 @@ def test_iscoroutinefunction_asyncio( assert_type(x, Callable[[str, int], Coroutine[str, int, bytes]]) if iscoroutinefunction(y): # pyright: ignore - assert_type(y, Callable[[str, int], Coroutine[Any, Any, bytes]]) + assert_type(y, Callable[[str, int], Awaitable[bytes]]) if iscoroutinefunction(z): # pyright: ignore - assert_type(z, Callable[[str, int], Coroutine[Any, Any, Any]]) + assert_type(z, Callable[[str, int], str | Awaitable[bytes]]) if iscoroutinefunction(xx): # pyright: ignore assert_type(xx, Callable[..., Coroutine[Any, Any, Any]]) @@ -31,10 +31,10 @@ def test_iscoroutinefunction_asyncio( assert_type(x, Callable[[str, int], Coroutine[str, int, bytes]]) if iscoroutinefunction(y): - assert_type(y, Callable[[str, int], Coroutine[Any, Any, bytes]]) + assert_type(y, Callable[[str, int], Awaitable[bytes]]) if iscoroutinefunction(z): - assert_type(z, Callable[[str, int], Coroutine[Any, Any, Any]]) + assert_type(z, Callable[[str, int], str | Awaitable[bytes]]) if iscoroutinefunction(xx): assert_type(xx, Callable[..., Coroutine[Any, Any, Any]]) From f7e25b328695569f8580d2bdf6a6254a85140733 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Sat, 20 Jun 2026 08:57:42 -0700 Subject: [PATCH 5/5] fix inspect tests Signed-off-by: Michael Carlstrom --- stdlib/@tests/test_cases/check_inspect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/@tests/test_cases/check_inspect.py b/stdlib/@tests/test_cases/check_inspect.py index e7ef3d25cf6e..37710ba3a5d3 100644 --- a/stdlib/@tests/test_cases/check_inspect.py +++ b/stdlib/@tests/test_cases/check_inspect.py @@ -17,10 +17,10 @@ def test_iscoroutinefunction_inspect( assert_type(x, Callable[[str, int], Coroutine[str, int, bytes]]) if inspect.iscoroutinefunction(y): - assert_type(y, Callable[[str, int], CoroutineType[Any, Any, bytes]]) + assert_type(y, Callable[[str, int], Awaitable[bytes]]) if inspect.iscoroutinefunction(z): - assert_type(z, Callable[[str, int], CoroutineType[Any, Any, Any]]) + assert_type(z, Callable[[str, int], str | Awaitable[bytes]]) if inspect.iscoroutinefunction(xx): assert_type(xx, Callable[..., CoroutineType[Any, Any, Any]])