From: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com> Date: Thu, 26 May 2022 19:33:40 +0000 (-0700) Subject: Add generic type parameters to FormData (#1651) X-Git-Tag: 0.20.1~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=14ef6bbbd6c5f03f0e1222a0a1b33ccc3a5f04cf;p=thirdparty%2Fstarlette.git Add generic type parameters to FormData (#1651) * Add generic type parameters to FormData * fix tests --- diff --git a/starlette/datastructures.py b/starlette/datastructures.py index 7aae90ec..f49dbc35 100644 --- a/starlette/datastructures.py +++ b/starlette/datastructures.py @@ -477,7 +477,7 @@ class UploadFile: await run_in_threadpool(self.file.close) -class FormData(ImmutableMultiDict): +class FormData(ImmutableMultiDict[str, typing.Union[UploadFile, str]]): """ An immutable multidict, containing both file uploads and text input. """ diff --git a/tests/test_formparsers.py b/tests/test_formparsers.py index 7418595c..b7f8cad8 100644 --- a/tests/test_formparsers.py +++ b/tests/test_formparsers.py @@ -24,7 +24,7 @@ FORCE_MULTIPART = ForceMultipartDict() async def app(scope, receive, send): request = Request(scope, receive) data = await request.form() - output = {} + output: typing.Dict[str, typing.Any] = {} for key, value in data.items(): if isinstance(value, UploadFile): content = await value.read() @@ -66,7 +66,7 @@ async def multi_items_app(scope, receive, send): async def app_with_headers(scope, receive, send): request = Request(scope, receive) data = await request.form() - output = {} + output: typing.Dict[str, typing.Any] = {} for key, value in data.items(): if isinstance(value, UploadFile): content = await value.read()