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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add annotations for _Error #1022

Merged
merged 2 commits into from Dec 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion jsonschema/exceptions.py
Expand Up @@ -6,6 +6,7 @@
from collections import defaultdict, deque
from pprint import pformat
from textwrap import dedent, indent
from typing import ClassVar
import heapq
import itertools

Expand All @@ -20,9 +21,13 @@


class _Error(Exception):

_word_for_schema_in_error_message: ClassVar[str]
_word_for_instance_in_error_message: ClassVar[str]

def __init__(
self,
message,
message: str,
validator=_unset,
path=(),
cause=None,
Expand Down Expand Up @@ -328,6 +333,7 @@ def by_relevance(weak=WEAK_MATCHES, strong=STRONG_MATCHES):
a collection of validation keywords to consider to be
"strong"
"""

def relevance(error):
validator = error.validator
return (
Expand All @@ -336,6 +342,7 @@ def relevance(error):
validator in strong,
not error._matches_type(),
)

return relevance


Expand Down