Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Features:

Other changes:

* *Backwards-incompatible*: The ``AsyncParser`` class has been removed, since
``Parser`` now provides async functionality.
Users should use ``await parser.async_parse()`` to access the async features
of ``Parser``.

* Drop support for Python 3.9, which is EOL (:pr:`1019`).
* Drop support for Bottle < 0.13 (:pr:`1019`).
* Drop support for Flask < 3.1.0 (:pr:`1023`).
Expand Down
3 changes: 1 addition & 2 deletions src/webargs/aiohttpparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def index(request, args):
from marshmallow import RAISE, Schema, ValidationError

from webargs import core
from webargs.asyncparser import AsyncParser
from webargs.core import json
from webargs.multidictproxy import MultiDictProxy

Expand Down Expand Up @@ -70,7 +69,7 @@ def _find_exceptions() -> None:
del _find_exceptions


class AIOHTTPParser(AsyncParser[web.Request]):
class AIOHTTPParser(core.Parser[web.Request]):
"""aiohttp request argument parser."""

DEFAULT_UNKNOWN_BY_LOCATION: dict[str, str | None] = {
Expand Down
40 changes: 0 additions & 40 deletions src/webargs/asyncparser.py

This file was deleted.

34 changes: 17 additions & 17 deletions tests/apps/aiohttp_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ class HelloSchema(ma.Schema):


async def echo(request):
parsed = await parser.parse(hello_args, request, location="query")
parsed = await parser.async_parse(hello_args, request, location="query")
return json_response(parsed)


async def echo_form(request):
parsed = await parser.parse(hello_args, request, location="form")
parsed = await parser.async_parse(hello_args, request, location="form")
return json_response(parsed)


async def echo_json(request):
try:
parsed = await parser.parse(hello_args, request, location="json")
parsed = await parser.async_parse(hello_args, request, location="json")
except json.JSONDecodeError as exc:
raise aiohttp.web.HTTPBadRequest(
text=json.dumps(["Invalid JSON."]),
Expand All @@ -46,7 +46,7 @@ async def echo_json(request):

async def echo_json_or_form(request):
try:
parsed = await parser.parse(hello_args, request, location="json_or_form")
parsed = await parser.async_parse(hello_args, request, location="json_or_form")
except json.JSONDecodeError as exc:
raise aiohttp.web.HTTPBadRequest(
text=json.dumps(["Invalid JSON."]),
Expand Down Expand Up @@ -74,27 +74,27 @@ async def echo_use_args_validated(request, args):

async def echo_ignoring_extra_data(request):
return json_response(
await parser.parse(hello_exclude_schema, request, unknown=None)
await parser.async_parse(hello_exclude_schema, request, unknown=None)
)


async def echo_multi(request):
parsed = await parser.parse(hello_multiple, request, location="query")
parsed = await parser.async_parse(hello_multiple, request, location="query")
return json_response(parsed)


async def echo_multi_form(request):
parsed = await parser.parse(hello_multiple, request, location="form")
parsed = await parser.async_parse(hello_multiple, request, location="form")
return json_response(parsed)


async def echo_multi_json(request):
parsed = await parser.parse(hello_multiple, request)
parsed = await parser.async_parse(hello_multiple, request)
return json_response(parsed)


async def echo_many_schema(request):
parsed = await parser.parse(hello_many_schema, request)
parsed = await parser.async_parse(hello_many_schema, request)
return json_response(parsed)


Expand All @@ -119,50 +119,50 @@ def always_fail(value):
raise ma.ValidationError("something went wrong")

args = {"text": fields.Str(validate=always_fail)}
parsed = await parser.parse(args, request)
parsed = await parser.async_parse(args, request)
return json_response(parsed)


async def echo_headers(request):
parsed = await parser.parse(hello_args, request, location="headers")
parsed = await parser.async_parse(hello_args, request, location="headers")
return json_response(parsed)


async def echo_cookie(request):
parsed = await parser.parse(hello_args, request, location="cookies")
parsed = await parser.async_parse(hello_args, request, location="cookies")
return json_response(parsed)


async def echo_nested(request):
args = {"name": fields.Nested({"first": fields.Str(), "last": fields.Str()})}
parsed = await parser.parse(args, request)
parsed = await parser.async_parse(args, request)
return json_response(parsed)


async def echo_multiple_args(request):
args = {"first": fields.Str(), "last": fields.Str()}
parsed = await parser.parse(args, request)
parsed = await parser.async_parse(args, request)
return json_response(parsed)


async def echo_nested_many(request):
args = {
"users": fields.Nested({"id": fields.Int(), "name": fields.Str()}, many=True)
}
parsed = await parser.parse(args, request)
parsed = await parser.async_parse(args, request)
return json_response(parsed)


async def echo_nested_many_data_key(request):
args = {
"x_field": fields.Nested({"id": fields.Int()}, many=True, data_key="X-Field")
}
parsed = await parser.parse(args, request)
parsed = await parser.async_parse(args, request)
return json_response(parsed)


async def echo_match_info(request):
parsed = await parser.parse(
parsed = await parser.async_parse(
{"mymatch": fields.Int()}, request, location="match_info"
)
return json_response(parsed)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_aiohttpparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def custom_handle_error(error, req, schema, *, error_status_code, error_headers)
raise CustomError("foo")

with pytest.raises(CustomError):
await parser.parse(
await parser.async_parse(
{"foo": fields.Int(required=True)}, web_request, location="query"
)

Expand All @@ -119,6 +119,6 @@ async def inner():
await inner()

with pytest.raises(CustomError):
await parser.parse(
await parser.async_parse(
{"foo": fields.Int(required=True)}, web_request, location="query"
)