Skip to content

Commit b4513dc

Browse files
committed
Add ID_OF to the protocol, and schemas are arbitrary mappings.
They aren't necessarily dicts.
1 parent d926288 commit b4513dc

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

jsonschema/protocols.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from __future__ import annotations
99

10+
from collections.abc import Callable, Mapping
1011
from typing import TYPE_CHECKING, Any, ClassVar, Iterable
1112
import sys
1213

@@ -78,12 +79,12 @@ class Validator(Protocol):
7879

7980
#: An object representing the validator's meta schema (the schema that
8081
#: describes valid schemas in the given version).
81-
META_SCHEMA: ClassVar[dict]
82+
META_SCHEMA: ClassVar[Mapping]
8283

8384
#: A mapping of validation keywords (`str`\s) to functions that
8485
#: validate the keyword with that name. For more information see
8586
#: `creating-validators`.
86-
VALIDATORS: ClassVar[dict]
87+
VALIDATORS: ClassVar[Mapping]
8788

8889
#: A `jsonschema.TypeChecker` that will be used when validating
8990
#: :kw:`type` keywords in JSON schemas.
@@ -93,19 +94,22 @@ class Validator(Protocol):
9394
#: :kw:`format` properties in JSON schemas.
9495
FORMAT_CHECKER: ClassVar[jsonschema.FormatChecker]
9596

96-
#: The schema that was passed in when initializing the object.
97-
schema: dict | bool
97+
#: A function which given a schema returns its ID.
98+
ID_OF: Callable[[Any], str | None]
99+
100+
#: The schema that will be used to validate instances
101+
schema: Mapping | bool
98102

99103
def __init__(
100104
self,
101-
schema: dict | bool,
105+
schema: Mapping | bool,
102106
resolver: RefResolver | None = None,
103107
format_checker: jsonschema.FormatChecker | None = None,
104108
) -> None:
105109
...
106110

107111
@classmethod
108-
def check_schema(cls, schema: dict) -> None:
112+
def check_schema(cls, schema: Mapping | bool) -> None:
109113
"""
110114
Validate the given schema against the validator's `META_SCHEMA`.
111115

0 commit comments

Comments
 (0)