diff --git a/src/flask/typing.py b/src/flask/typing.py index 30c9398c..6bbdb1dd 100644 --- a/src/flask/typing.py +++ b/src/flask/typing.py @@ -7,7 +7,13 @@ if t.TYPE_CHECKING: # pragma: no cover # The possible types that are directly convertible or are a Response object. ResponseValue = t.Union[ - "Response", str, bytes, list, t.Dict[str, t.Any], t.Iterator[str], t.Iterator[bytes] + "Response", + str, + bytes, + t.List[t.Any], + t.Dict[str, t.Any], + t.Iterator[str], + t.Iterator[bytes], ] # the possible types for an individual HTTP header diff --git a/tests/typing/typing_route.py b/tests/typing/typing_route.py index 9c518938..41973c26 100644 --- a/tests/typing/typing_route.py +++ b/tests/typing/typing_route.py @@ -25,7 +25,17 @@ def hello_bytes() -> bytes: @app.route("/json") def hello_json() -> Response: - return jsonify({"response": "Hello, World!"}) + return jsonify("Hello, World!") + + +@app.route("/json/dict") +def hello_json_dict() -> t.Dict[str, t.Any]: + return {"response": "Hello, World!"} + + +@app.route("/json/dict") +def hello_json_list() -> t.List[t.Any]: + return [{"message": "Hello"}, {"message": "World"}] @app.route("/generator")