typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

Reflect deprecation for `asyncio.iscoroutinefunction`

Open Avasam opened this issue 6 months ago • 3 comments

#12558 by @ZeroIntensity (since the branch was deleted) but without the Python 3.16 mention

I didn't scope the deprecation to only 3.14+ because I think any non-EOL Python version has a migration path. (I don't remember if we have exact guidelines on deprecated decorator)

Avasam avatar May 15 '25 17:05 Avasam

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

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/worker.py:73:44: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ aiohttp/worker.py:73:44: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-deprecated for more info  [deprecated]

core (https://github.com/home-assistant/core)
+ homeassistant/util/__init__.py:128: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/core.py:388: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/http.py:48: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/frame.py:385: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/trigger.py:269: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/service.py:1161: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/condition.py:247: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]

github-actions[bot] avatar May 15 '25 17:05 github-actions[bot]

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

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/worker.py:73:44: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ aiohttp/worker.py:73:44: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-deprecated for more info  [deprecated]

core (https://github.com/home-assistant/core)
+ homeassistant/util/__init__.py:128: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/core.py:388: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/http.py:48: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/frame.py:385: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/trigger.py:269: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/service.py:1161: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/condition.py:247: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]

github-actions[bot] avatar May 15 '25 20:05 github-actions[bot]

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

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/worker.py:73:44: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ aiohttp/worker.py:73:44: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-deprecated for more info  [deprecated]

core (https://github.com/home-assistant/core)
+ homeassistant/util/__init__.py:128: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/core.py:388: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/http.py:48: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/frame.py:385: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/trigger.py:269: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/service.py:1161: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ homeassistant/helpers/condition.py:247: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]

github-actions[bot] avatar May 16 '25 17:05 github-actions[bot]

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

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/worker.py:73:44: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ aiohttp/worker.py:73:44: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-deprecated for more info  [deprecated]

github-actions[bot] avatar Jul 25 '25 17:07 github-actions[bot]

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

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/worker.py:73:44: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Use inspect.iscoroutinefunction instead  [deprecated]
+ aiohttp/worker.py:73:44: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-deprecated for more info  [deprecated]

github-actions[bot] avatar Jul 25 '25 18:07 github-actions[bot]

If I understand it correctly, it's sometimes necessary to use this on Python < 3.11, since it supports @coroutine (removed in 3.11), which the inspect version doesn't support.

srittau avatar Jul 26 '25 03:07 srittau

I'll close this in favor of @max-muoto 's #14289 . In which the tests are also already updated to keep testing both methods.

Avasam avatar Jul 27 '25 03:07 Avasam

I'll close this in favor of @max-muoto 's #14289 . In which the tests are also already updated to keep testing both methods.

Avasam avatar Jul 27 '25 03:07 Avasam