@@ -4,9 +4,6 @@ from contextlib import contextmanager
44from typing import Any , ClassVar
55from typing_extensions import TypeAlias
66
7- from referencing .jsonschema import Schema , SchemaRegistry
8- from referencing .typing import URI
9-
107from ._format import FormatChecker
118from ._types import TypeChecker
129from ._utils import Unset , URIDict
@@ -17,6 +14,8 @@ _JsonObject: TypeAlias = Mapping[str, Any]
1714_JsonValue : TypeAlias = _JsonObject | list [Any ] | str | int | float | bool | None
1815_ValidatorCallback : TypeAlias = Callable [[Any , Any , _JsonValue , _JsonObject ], Iterator [ValidationError ]]
1916
17+ _Schema : TypeAlias = Mapping [str , Any ]
18+
2019# This class does not exist at runtime. Compatible classes are created at
2120# runtime by create().
2221class _Validator :
@@ -25,45 +24,31 @@ class _Validator:
2524 TYPE_CHECKER : ClassVar [Incomplete ]
2625 FORMAT_CHECKER : ClassVar [Incomplete ]
2726 @staticmethod
28- def ID_OF (contents : Schema ) -> URI | None : ...
29- schema : Schema
30- format_checker : FormatChecker | None
31- def __init__ (
32- self ,
33- schema : Schema ,
34- resolver : Incomplete | None = None ,
35- format_checker : FormatChecker | None = None ,
36- * ,
37- registry : SchemaRegistry = ...,
38- _resolver : Incomplete | None = None ,
39- ) -> None : ...
27+ def ID_OF (schema : _Schema ) -> str : ...
28+ schema : _Schema
29+ resolver : Incomplete
30+ format_checker : Incomplete
31+ evolve : Incomplete
32+ def __init__ (self , schema : _Schema , resolver : Incomplete | None = ..., format_checker : Incomplete | None = ...) -> None : ...
4033 @classmethod
41- def check_schema (cls , schema : Schema , format_checker : FormatChecker | Unset = ...) -> None : ...
42- @property
43- def resolver (self ): ...
44- def evolve (self , ** changes ) -> _Validator : ...
45- def iter_errors (self , instance , _schema : Schema | None = ...) -> Generator [Incomplete , None , None ]: ...
34+ def check_schema (cls , schema : _Schema , format_checker : FormatChecker | Unset = ...) -> None : ...
35+ def iter_errors (self , instance , _schema : _Schema | None = ...) -> Generator [Incomplete , None , None ]: ...
4636 def descend (
47- self ,
48- instance ,
49- schema : Schema ,
50- path : Incomplete | None = ...,
51- schema_path : Incomplete | None = ...,
52- resolver : Incomplete | None = None ,
37+ self , instance , schema : _Schema , path : Incomplete | None = ..., schema_path : Incomplete | None = ...
5338 ) -> Generator [Incomplete , None , None ]: ...
5439 def validate (self , * args , ** kwargs ) -> None : ...
5540 def is_type (self , instance , type ): ...
56- def is_valid (self , instance , _schema : Schema | None = ...) -> bool : ...
41+ def is_valid (self , instance , _schema : _Schema | None = ...) -> bool : ...
5742
5843def validates (version : str ) -> Callable [..., Incomplete ]: ...
5944def create (
60- meta_schema : Schema ,
45+ meta_schema : _Schema ,
6146 validators : Mapping [str , _ValidatorCallback ] | tuple [()] = (),
6247 version : Incomplete | None = None ,
6348 type_checker : TypeChecker = ...,
6449 format_checker : FormatChecker = ...,
65- id_of : Callable [[Schema ], str ] = ...,
66- applicable_validators : Callable [[Schema ], Iterable [tuple [str , _ValidatorCallback ]]] = ...,
50+ id_of : Callable [[_Schema ], str ] = ...,
51+ applicable_validators : Callable [[_Schema ], Iterable [tuple [str , _ValidatorCallback ]]] = ...,
6752) -> type [_Validator ]: ...
6853def extend (
6954 validator ,
@@ -99,7 +84,7 @@ class RefResolver:
9984 remote_cache : Incomplete | None = None ,
10085 ) -> None : ...
10186 @classmethod
102- def from_schema (cls , schema : Schema , id_of = ..., * args , ** kwargs ): ...
87+ def from_schema (cls , schema : _Schema , id_of = ..., * args , ** kwargs ): ...
10388 def push_scope (self , scope ) -> None : ...
10489 def pop_scope (self ) -> None : ...
10590 @property
@@ -115,5 +100,5 @@ class RefResolver:
115100 def resolve_fragment (self , document , fragment ): ...
116101 def resolve_remote (self , uri ): ...
117102
118- def validate (instance : object , schema : Schema , cls : type [_Validator ] | None = None , * args : Any , ** kwargs : Any ) -> None : ...
119- def validator_for (schema : Schema | bool , default = ...): ...
103+ def validate (instance : object , schema : _Schema , cls : type [_Validator ] | None = None , * args : Any , ** kwargs : Any ) -> None : ...
104+ def validator_for (schema : _Schema | bool , default = ...): ...
0 commit comments