python-jsonschema / check-jsonschema

A CLI and set of pre-commit hooks for jsonschema validation with built-in support for GitHub Workflows, Renovate, Azure Pipelines, and more!
https://check-jsonschema.readthedocs.io/en/stable
Other
192 stars 38 forks source link

Introduce 'best deep match' heuristic #303

Closed sirosen closed 10 months ago

sirosen commented 10 months ago

And also print a small hint that --verbose should be used to try to see all errors.

Tests are just tweaked a little to catch this in the output, but a sample of the new rendering... image

Hopefully, this can guide people towards --verbose more often when they need it, and the "best deep match" might surface better things for certain schemas. The whole space of guessing which error to show is kind of dicey though -- I tried various priorities for different validators and found that it always depends on how the schema was written.