Validation errors should be able to indicate that a single error should be produced without collecting all of the details ahead of time

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

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

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

評価

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

調査の方向性

まず anyOf、oneOf、dependentRequired の検証パスをたどり、次に ValidationError.init がコンテキストをどのように受け取るかを調べます。すべてのサブエラーを収集せずに検証エラーを返せるようになり、その完全な内容は要求されたときにのみ計算されれば完了です。

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

説明

Dialects v2 Enhancement Error Reporting

In general, validation is lazy -- if only one error is needed (in the sense that it is known that an instance is invalid), only one is produced.

There are however (somewhat unintentional) exceptions.

E.g.:

  • anyOf and oneOf calculate the .context of the first error they yield by calculating all sub-errors that were generated. This is because ValidationError.context needs to be provided on __init__.
  • dependentRequired, on the other hand, yields many errors, one for each missing required property (see also #119)

What's happening in these situations is that the validation function knows an error has occurred -- it wants to yield an error, but in order to do so, it needs to calculate the full details required so that the error is "complete".

We should instead have a way to indicate a validation error has occurred, but delay fully calculating its contents until/unless they are requested.

主要言語
Python
スター
5k
フォーク
741
平均マージ
4日 17時間
マージ済み PR(30日)
6

環境構築

はじめの一歩

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

python-jsonschema/jsonschema のほかの issue

python-jsonschema/jsonschema の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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