jsonschema icon indicating copy to clipboard operation
jsonschema copied to clipboard

Wrong comment in relevance function?

Open mmarseu opened this issue 1 year ago • 1 comments

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.

https://github.com/python-jsonschema/jsonschema/blob/d47db265f4656c667035244892e7f80cce69624d/jsonschema/exceptions.py#L411-L413

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:

https://github.com/python-jsonschema/jsonschema/blob/d47db265f4656c667035244892e7f80cce69624d/jsonschema/exceptions.py#L438-L440

mmarseu avatar Jan 14 '25 13:01 mmarseu

Yes that seems correct (i.e. the first comment seems wrong). PR welcome certainly.

Julian avatar Jan 16 '25 18:01 Julian