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()