diff options
-rw-r--r-- | .pre-commit-config.yaml | 1 | ||||
-rw-r--r-- | jsonschema/exceptions.py | 9 |
2 files changed, 9 insertions, 1 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7c4dce8..0e1a3fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,6 @@ repos: rev: v4.4.0 hooks: - id: check-ast - - id: check-docstring-first - id: check-json - id: check-toml - id: check-vcs-permalinks diff --git a/jsonschema/exceptions.py b/jsonschema/exceptions.py index 87db3df..55c3ae7 100644 --- a/jsonschema/exceptions.py +++ b/jsonschema/exceptions.py @@ -340,6 +340,15 @@ def by_relevance(weak=WEAK_MATCHES, strong=STRONG_MATCHES): relevance = by_relevance() +""" +A key function (e.g. to use with `sorted`) which sorts errors by relevance. + +Example: + +.. code:: python + + sorted(validator.iter_errors(12), key=jsonschema.exceptions.relevance) +""" def best_match(errors, key=relevance): |