Repository navigation
Use inspect.iscoroutinefunction instead of the deprecated asyncio.iscoroutinefunction - #950
Open
PiotrCzapla wants to merge 1 commit into
Open
PiotrCzapla wants to merge 1 commit into
PiotrCzapla wants to merge 1 commit into
Conversation
PiotrCzapla
marked this pull request as ready for review
October 19, 2026 15:48
…oroutinefunction This addresses a warning that `iscoroutinefunction` has moved to `inspect` since 3.5 when `async def` was introduced. Using the `asyncio` made sense up until Python 3.11 which removes the `@asyncio.coroutine` decorator the only difference between old asyncio and inspect versions. Claude note below: Python 3.14 deprecates `asyncio.iscoroutinefunction`, and 3.16 removes it, so every call emits a `DeprecationWarning`. This switches fastcore's three uses to `inspect.iscoroutinefunction`: `is_async_callable` (aio), `parallel_async_gen` (parallel) and `flexicache` (xtras). The two return the same result for plain coroutine functions, `functools.partial` of them and `unittest.mock.AsyncMock`, checked on Python 3.10, 3.12 and 3.13. The asyncio version also accepted the `@asyncio.coroutine` decorator, which Python 3.11 removed. Tests: `nbdev-test` passes for `03c_aio` and `03a_parallel` on Python 3.14. `03_xtras` stops at an unrelated cell, `Person(name="Bob")` raising `TypeError`, which fails the same way on `main` under 3.14. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PiotrCzapla
force-pushed
the
inspect-iscoroutinefunction
branch
from
October 19, 2026 16:02
15053a7 to
4281c3d
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This addresses a warning that
iscoroutinefunctionhas moved toinspectsince 3.5 whenasync defwas introduced. Using theasynciomade sense up until Python 3.11 which removes the@asyncio.coroutinedecorator the only difference between old asyncio and inspect versions.Claude note below:
Python 3.14 deprecates
asyncio.iscoroutinefunction, and 3.16 removes it, so every call emits aDeprecationWarning. This switches fastcore's three uses toinspect.iscoroutinefunction:is_async_callable(aio),parallel_async_gen(parallel) andflexicache(xtras).The two return the same result for plain coroutine functions,
functools.partialof them andunittest.mock.AsyncMock, checked on Python 3.10, 3.12 and 3.13. The asyncio version also accepted the@asyncio.coroutinedecorator, which Python 3.11 removed.Tests:
nbdev-testpasses for03c_aioand03a_parallelon Python 3.14.03_xtrasstops at an unrelated cell,Person(name="Bob")raisingTypeError, which fails the same way onmainunder 3.14.