Skip to content
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

Wrong comment in relevance function? #1325

Open
mmarseu opened this issue Jan 14, 2025 · 0 comments
Open

Wrong comment in relevance function? #1325

mmarseu opened this issue Jan 14, 2025 · 0 comments

Comments

@mmarseu
Copy link

mmarseu commented Jan 14, 2025

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.

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:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant