From ae79d03add1fae39af2c877f9b96eed030d64ac0 Mon Sep 17 00:00:00 2001 From: Sanjays2402 <51058514+Sanjays2402@users.noreply.github.com> Date: Thu, 2 Jul 2026 00:42:10 -0700 Subject: [PATCH] Modernize aiohttpparser docstring example (remove removed asyncio.coroutine) 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'. --- src/webargs/aiohttpparser.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/webargs/aiohttpparser.py b/src/webargs/aiohttpparser.py index 00660614..774e1b9a 100644 --- a/src/webargs/aiohttpparser.py +++ b/src/webargs/aiohttpparser.py @@ -2,7 +2,6 @@ Example: :: - import asyncio from aiohttp import web from webargs import fields @@ -12,9 +11,8 @@ hello_args = {"name": fields.Str(required=True)} - @asyncio.coroutine @use_args(hello_args) - def index(request, args): + async def index(request, args): return web.Response(body="Hello {}".format(args["name"]).encode("utf-8"))