Skip to content

Conversation

@max-muoto
Copy link
Contributor

@max-muoto max-muoto commented Dec 25, 2025

This PR adds the asyncio.iscoroutinefunction deprecations from #14289 with the only core change being that we only deprecate them for >= 3.11 due to @srittau's feedback here: #14074 (comment)

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/web_urldispatcher.py:159:44: error: overload def [_P, _T] (func: def (*_P.args, **_P.kwargs) -> typing.Awaitable[_T`-2]) -> TypeGuard[def (*_P.args, **_P.kwargs) -> typing.Coroutine[Any, Any, _T`-2]] of function asyncio.coroutines.iscoroutinefunction is deprecated: Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead  [deprecated]
+ aiohttp/web_urldispatcher.py:159:44: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-deprecated for more info  [deprecated]
+ aiohttp/web_urldispatcher.py:167:44: error: overload def [_P, _T] (func: def (*_P.args, **_P.kwargs) -> typing.Awaitable[_T`-2]) -> TypeGuard[def (*_P.args, **_P.kwargs) -> typing.Coroutine[Any, Any, _T`-2]] of function asyncio.coroutines.iscoroutinefunction is deprecated: Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead  [deprecated]
+ aiohttp/worker.py:68:44: error: overload def [_P] (func: def (*_P.args, **_P.kwargs) -> builtins.object) -> TypeGuard[def (*_P.args, **_P.kwargs) -> typing.Coroutine[Any, Any, Any]] of function asyncio.coroutines.iscoroutinefunction is deprecated: Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead  [deprecated]

@max-muoto max-muoto marked this pull request as ready for review December 25, 2025 20:44
Copy link
Contributor

@donbarbos donbarbos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, just suggestion about messages.
PR: python/cpython#122875


if sys.version_info >= (3, 11):
@overload
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")

@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ...
@overload
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")

@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ...
@overload
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")

@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ...
@overload
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants