-
-
Notifications
You must be signed in to change notification settings - Fork 592
ValidationError __str__ is far too verbose on large objects #748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi there. This is essentially a dupe of #243, at least #243 (comment) Certainly happy to review a PR that uses |
(Error messages already should subselect the relevant portion of an object) |
Yep, fair enough. Let's close this, and I'll have a proper read over there and see if I can figure out a solution. |
Yeah, they do sub-select, I was just looking at a top-level error. |
For posterity, if anyone wants a short workaround, just catch the error, remove instance, and re-raise: try:
validate(instance=jsonfile, schema=schema, resolver=resolver)
except jsonschema.exceptions.ValidationError as e:
e.instance = "<Omitted>"
raise Thanks Julian for writing and maintaining this library! |
I have some objects that are not particularly complex, but have a large number of elements (a few nested arrays with up to 150 elements at some levels).
If I hit a ValidationError (e.g. during testing), then the error is massive - more lines than my terminal retains. I've never seen such a large error in python, and it makes testing difficult, because I can't see the backtrace.
A few possibilities for solutions:
error.schema
anderror.instance
, orHappy to submit a PR for either of these, after your feedback on the ideas.
The text was updated successfully, but these errors were encountered: