@@ -4,9 +4,6 @@ from contextlib import contextmanager
4
4
from typing import Any , ClassVar
5
5
from typing_extensions import TypeAlias
6
6
7
- from referencing .jsonschema import Schema , SchemaRegistry
8
- from referencing .typing import URI
9
-
10
7
from ._format import FormatChecker
11
8
from ._types import TypeChecker
12
9
from ._utils import Unset , URIDict
@@ -17,6 +14,8 @@ _JsonObject: TypeAlias = Mapping[str, Any]
17
14
_JsonValue : TypeAlias = _JsonObject | list [Any ] | str | int | float | bool | None
18
15
_ValidatorCallback : TypeAlias = Callable [[Any , Any , _JsonValue , _JsonObject ], Iterator [ValidationError ]]
19
16
17
+ _Schema : TypeAlias = Mapping [str , Any ]
18
+
20
19
# This class does not exist at runtime. Compatible classes are created at
21
20
# runtime by create().
22
21
class _Validator :
@@ -25,45 +24,31 @@ class _Validator:
25
24
TYPE_CHECKER : ClassVar [Incomplete ]
26
25
FORMAT_CHECKER : ClassVar [Incomplete ]
27
26
@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 : ...
40
33
@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 ]: ...
46
36
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 = ...
53
38
) -> Generator [Incomplete , None , None ]: ...
54
39
def validate (self , * args , ** kwargs ) -> None : ...
55
40
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 : ...
57
42
58
43
def validates (version : str ) -> Callable [..., Incomplete ]: ...
59
44
def create (
60
- meta_schema : Schema ,
45
+ meta_schema : _Schema ,
61
46
validators : Mapping [str , _ValidatorCallback ] | tuple [()] = (),
62
47
version : Incomplete | None = None ,
63
48
type_checker : TypeChecker = ...,
64
49
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 ]]] = ...,
67
52
) -> type [_Validator ]: ...
68
53
def extend (
69
54
validator ,
@@ -99,7 +84,7 @@ class RefResolver:
99
84
remote_cache : Incomplete | None = None ,
100
85
) -> None : ...
101
86
@classmethod
102
- def from_schema (cls , schema : Schema , id_of = ..., * args , ** kwargs ): ...
87
+ def from_schema (cls , schema : _Schema , id_of = ..., * args , ** kwargs ): ...
103
88
def push_scope (self , scope ) -> None : ...
104
89
def pop_scope (self ) -> None : ...
105
90
@property
@@ -115,5 +100,5 @@ class RefResolver:
115
100
def resolve_fragment (self , document , fragment ): ...
116
101
def resolve_remote (self , uri ): ...
117
102
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