Modernize aiohttpparser docstring example (remove removed asyncio.coroutine)#1076
Merged
sloria merged 1 commit intoJul 2, 2026
Conversation
…outine)
The module docstring's usage example decorated a plain generator
function with @asyncio.coroutine:
@asyncio.coroutine
@use_args(hello_args)
def index(request, args):
...
asyncio.coroutine was deprecated in Python 3.8 and REMOVED in Python
3.11, so copy-pasting this example raises AttributeError on every
Python version webargs supports (>=3.10; 3.11-3.14 have no
asyncio.coroutine). The parser's own code already uses async def /
await, and examples/aiohttp_example.py uses 'async def index'.
Update the example to modern async def to match, and drop the now-unused
'import asyncio'.
Member
|
thanks! |
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.
Summary
The
aiohttpparsermodule docstring's usage example decorates a plain generator function with@asyncio.coroutine:asyncio.coroutinewas deprecated in Python 3.8 and removed in Python 3.11. webargs declares support for Python 3.10–3.14 (requires-python = ">=3.10"), and on 3.11+ there is noasyncio.coroutine, so anyone copy-pasting this example hits:The parser's own implementation already uses
async def/await, andexamples/aiohttp_example.pyusesasync def index(request, args). The docstring is just stale.Fix
Modernize the example to
async def(matching the repo's own example) and drop the now-unusedimport asyncio. Docstring-only change; no runtime code touched.Verification
asyncio.coroutinedoes not exist on Python 3.11+ (hasattr(asyncio, "coroutine")isFalse).import webargs.aiohttpparsersucceeds after the change.ast.parsed it — valid Python.