Skip to content

Commit 8304e41

Browse files
committed
Add a docstring-ish for exceptions.relevance.
check-docstring-first has to go unfortunately due to pre-commit/pre-commit-hooks#159.
1 parent 1254be0 commit 8304e41

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ repos:
55
rev: v4.4.0
66
hooks:
77
- id: check-ast
8-
- id: check-docstring-first
98
- id: check-json
109
- id: check-toml
1110
- id: check-vcs-permalinks

jsonschema/exceptions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,15 @@ def relevance(error):
340340

341341

342342
relevance = by_relevance()
343+
"""
344+
A key function (e.g. to use with `sorted`) which sorts errors by relevance.
345+
346+
Example:
347+
348+
.. code:: python
349+
350+
sorted(validator.iter_errors(12), key=jsonschema.exceptions.relevance)
351+
"""
343352

344353

345354
def best_match(errors, key=relevance):

0 commit comments

Comments
 (0)