Consider an API which collects validation errors and raises an exception group

Open
#1,011 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 6 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
python

Research direction

Start by reading the existing Validator.iter_errors, Validator.is_valid, and Validator.validate APIs, then review PEP 654 on exception groups and PEP 678 on exception notes. Define whether a new API should raise all validation errors, how it relates to the existing methods, and what completed behavior and compatibility expectations would be.

Written by the indexing model from the issue text.

Description

Dialects v2 Enhancement Error Reporting

Python 3.11 now supports exception groups for grouping together multiple (simultaneous, unrelated) exceptions.

This seems to suit us -- right now we have:

  • Validator.iter_errors, aimed at returning (not raising) all errors
  • Validator.is_valid, aimed at returning no errors and indicating via a boolean whether things are OK
  • Validator.validate, aimed at raising 1 single exception (the first encountered one)

Another API where we raise all exceptions iter_errors would have returned seems like it may fit the picture.

Reviewing the notes API to see if we should make any use of it is likely also wise.

Dominant language
Python
Stars
5k
Forks
741
Avg merge
4d 17h
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-jsonschema/jsonschema

All issues in python-jsonschema/jsonschema

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.