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