RFC: Use annotations for parsing arguments

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
28/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
api, backend

調査の方向性

まず webargs-starlette の proof of concept を確認し、次に AsyncParser と core.Parser、および marshmallow Schema.TYPE_MAPPING がどのようにフィールドを構築するかを調査します。完了条件は、アノテーションベースの use_annotations アプローチを関連するパーサーに適用し、リクエスト引数がビュー関数のアノテーションからパースされるようにすることです。

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

説明

feedback welcome

Add a decorator that will parse request arguments from the view function's type annotations.

I've built a working proof of concept of this idea in webargs-starlette.

@app.route("/")
@use_annotations(locations=("query",))
async def index(request, name: str = "World"):
    return JSONResponse({"Hello": name})

A marshmallow Schema is generated from the annotations using Schema.TYPE_MAPPING to construct fields.

The code for use_annotations mostly isn't tied to Starlette and could be adapted for AsyncParser (and core.Parser when we drop Python 2 support).

主要言語
Python
スター
1.4k
フォーク
171
平均マージ
8時間 47分
マージ済み PR(30日)
12

環境構築

はじめの一歩

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

marshmallow-code/webargs のほかの issue

marshmallow-code/webargs の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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