Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Should `quart.make_response` be typed as returning `Response`?

オープン
#288 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

quart.make_response のエントリーポイントから開始し、報告された mypy エラーおよび Flask の動作と照らし合わせて、その戻り値の型付けを調査してください。提供された Quart の例が、ResponseTypes を必要とせずに Response の戻り値アノテーションで型チェックを通過すれば完了です。可能であれば、リポジトリの関連する typing テストで変更を検証してください。

索引モデルが issue の本文から書いたものです。

説明

Steps to reproduce

With the following Quart app:

from quart import Response, make_response
from quart_trio import QuartTrio

app = QuartTrio(__name__)


@app.route("/")
async def hello_world() -> Response:
    return await make_response("<p>Hello, World!</p>")


if __name__ == "__main__":
    app.run()

mypy fails because make_response does not return a Response:

quart_app.py:9: error: Incompatible return value type (got "quart.wrappers.response.Response | werkzeug.wrappers.response.Response", expected "quart.wrappers.response.Response")  [return-value]

Expected result

I would expect validation to pass. Indeed, the equivalent Flask app passes validation:

from flask import Flask, Response, make_response

app = Flask(__name__)


@app.route("/")
def hello_world() -> Response:
    return make_response("<p>Hello, World!</p>")

Workarounds

  1. Use return "<p>Hello, World!</p>" and mark the return type as str. But figuring out the right type is tiring, is a maintenance burden and arguably introduces unnecessary variation in the code.
  2. Use return quart.Response("<p>Hello, World!</p>") but it quickly breaks for more complex types. I spent a lot of time trying to understand why quart.Response({"headers": "foo", "params': "bar"}) was returning "headersparams"!
  3. Type the return as quart.typing. ResponseTypes. This is what I'm doing right now in the urllib3 tests (https://github.com/urllib3/urllib3/pull/3193) but I would rather use Response.

Environment

  • Python version: 3.12.0
  • Quart version: 0.19.3 (quart-trio 0.11.0)
主要言語
Python
スター
3.7k
フォーク
209
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pallets/quart のほかの issue

pallets/quart の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。