python-jsonschema / python-jsonschema/jsonschema

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

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

Nobody has claimed this yet.

Dialects v2 Enhancement Error Reporting
Dominant language
Python
Stars
5k
Forks
671
Avg merge
1d 1h
Merged PRs (30d)
10

Description

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.

Contributor guide

Open the contributing guide

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.

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.