-
-
Notifications
You must be signed in to change notification settings - Fork 595
Open
Description
When looking at the way jsonschema.exceptions.best_match
works to figure out a way to better interpret jsonschema errors, I was mislead by what I believe to be a wrong comment.
jsonschema/jsonschema/exceptions.py
Lines 411 to 413 in d47db26
return ( # prefer errors which are ... | |
-len(error.path), # 'deeper' and thereby more specific | |
error.path, # earlier (for sibling errors) |
In line 412, you're saying errors which are deeper (i.e., longer path) are preferred but the code is actually doing the opposite. It prefers errors with shorter paths. Am I correct? This behavior would be in line with the documentation of the best_match
function:
jsonschema/jsonschema/exceptions.py
Lines 438 to 440 in d47db26
In general, errors that are higher up in the instance (i.e. for which | |
`ValidationError.path` is shorter) are considered better matches, | |
since they indicate "more" is wrong with the instance. |
Metadata
Metadata
Assignees
Labels
No labels