Skip to content

Reflect deprecation for asyncio.iscoroutinefunction #14074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from asyncio import iscoroutinefunction
from collections.abc import Awaitable, Callable, Coroutine
from inspect import iscoroutinefunction
from typing import Any
from typing_extensions import assert_type

Expand All @@ -16,10 +16,10 @@
assert_type(x, Callable[[str, int], Coroutine[str, int, bytes]])

if iscoroutinefunction(y):
assert_type(y, Callable[[str, int], Coroutine[Any, Any, bytes]])

Check failure on line 19 in stdlib/@tests/test_cases/inspect/check_coroutines.py

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

"assert_type" mismatch: expected "(str, int) -> Coroutine[Any, Any, bytes]" but received "(str, int) -> CoroutineType[Any, Any, bytes]" (reportAssertTypeFailure)

if iscoroutinefunction(z):
assert_type(z, Callable[[str, int], Coroutine[Any, Any, Any]])

Check failure on line 22 in stdlib/@tests/test_cases/inspect/check_coroutines.py

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

"assert_type" mismatch: expected "(str, int) -> Coroutine[Any, Any, Any]" but received "(str, int) -> CoroutineType[Any, Any, Any]" (reportAssertTypeFailure)

if iscoroutinefunction(xx):
assert_type(xx, Callable[..., Coroutine[Any, Any, Any]])

Check failure on line 25 in stdlib/@tests/test_cases/inspect/check_coroutines.py

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

"assert_type" mismatch: expected "(...) -> Coroutine[Any, Any, Any]" but received "(...) -> CoroutineType[Any, Any, Any]" (reportAssertTypeFailure)
6 changes: 5 additions & 1 deletion stdlib/asyncio/coroutines.pyi
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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]]: ...
Loading