1
- from typing import Any , List , NamedTuple , Optional , Pattern
1
+ from re import Pattern
2
+ from typing import Any , NamedTuple
2
3
3
4
from coreschema .compat import numeric_types as numeric_types
4
5
from coreschema .compat import text_types as text_types
@@ -7,16 +8,16 @@ from coreschema.utils import uniq as uniq
7
8
8
9
class Error (NamedTuple ):
9
10
text : str
10
- index : List [str ] # type: ignore [assignment]
11
+ index : list [str ] # type: ignore [assignment]
11
12
12
- def push_index (errors : List [Error ], key : Any ) -> List [str ]: ...
13
+ def push_index (errors : list [Error ], key : Any ) -> list [str ]: ...
13
14
14
15
class Schema :
15
- errors : List [Error ] = ...
16
+ errors : list [Error ] = ...
16
17
title : Any = ...
17
18
description : Any = ...
18
19
default : Any = ...
19
- def __init__ (self , title : str = ..., description : str = ..., default : Optional [ Any ] = ...) -> None : ...
20
+ def __init__ (self , title : str = ..., description : str = ..., default : Any | None = ...) -> None : ...
20
21
def make_error (self , code : str ) -> Error : ...
21
22
def __or__ (self , other : Schema ) -> Union : ...
22
23
def __and__ (self , other : Schema ) -> Intersection : ...
@@ -25,137 +26,137 @@ class Schema:
25
26
def __eq__ (self , other : Schema ) -> bool : ... # type: ignore [override]
26
27
27
28
class Object (Schema ):
28
- errors : List [Error ] = ...
29
+ errors : list [Error ] = ...
29
30
additional_properties_schema : Any = ...
30
31
properties : Any = ...
31
- required : Optional [ bool ] = ...
32
+ required : bool | None = ...
32
33
max_properties : int = ...
33
34
min_properties : int = ...
34
35
pattern_properties : Any = ...
35
36
additional_properties : Any = ...
36
37
pattern_properties_regex : Any = ...
37
38
def __init__ (
38
39
self ,
39
- properties : Optional [ Any ] = ...,
40
- required : Optional [ bool ] = ...,
41
- max_properties : Optional [ Any ] = ...,
42
- min_properties : Optional [ Any ] = ...,
43
- pattern_properties : Optional [ Any ] = ...,
40
+ properties : Any | None = ...,
41
+ required : bool | None = ...,
42
+ max_properties : Any | None = ...,
43
+ min_properties : Any | None = ...,
44
+ pattern_properties : Any | None = ...,
44
45
additional_properties : bool = ...,
45
46
** kwargs : Any
46
47
) -> None : ...
47
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
48
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
48
49
49
50
class Array (Schema ):
50
- errors : List [Error ] = ...
51
+ errors : list [Error ] = ...
51
52
items : Schema = ...
52
53
max_items : int = ...
53
54
min_items : int = ...
54
55
unique_items : int = ...
55
56
additional_items : int = ...
56
57
def __init__ (
57
58
self ,
58
- items : Optional [ Any ] = ...,
59
- max_items : Optional [ Any ] = ...,
60
- min_items : Optional [ Any ] = ...,
59
+ items : Any | None = ...,
60
+ max_items : Any | None = ...,
61
+ min_items : Any | None = ...,
61
62
unique_items : bool = ...,
62
63
additional_items : bool = ...,
63
64
** kwargs : Any
64
65
) -> None : ...
65
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
66
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
66
67
67
68
class Number (Schema ):
68
69
integer_only : bool = ...
69
- errors : List [Error ] = ...
70
+ errors : list [Error ] = ...
70
71
minimum : int = ...
71
72
maximum : int = ...
72
73
exclusive_minimum : int = ...
73
74
exclusive_maximum : int = ...
74
- multiple_of : Optional [ int ] = ...
75
+ multiple_of : int | None = ...
75
76
def __init__ (
76
77
self ,
77
- minimum : Optional [ int ] = ...,
78
- maximum : Optional [ int ] = ...,
78
+ minimum : int | None = ...,
79
+ maximum : int | None = ...,
79
80
exclusive_minimum : bool = ...,
80
81
exclusive_maximum : bool = ...,
81
- multiple_of : Optional [ int ] = ...,
82
+ multiple_of : int | None = ...,
82
83
** kwargs : Any
83
84
) -> None : ...
84
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
85
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
85
86
86
87
class Integer (Number ):
87
- errors : List [Error ] = ...
88
+ errors : list [Error ] = ...
88
89
integer_only : bool = ...
89
90
90
91
class String (Schema ):
91
- errors : List [Error ] = ...
92
+ errors : list [Error ] = ...
92
93
max_length : Any = ...
93
94
min_length : Any = ...
94
95
pattern : str = ...
95
96
format : str = ...
96
97
pattern_regex : Pattern [str ] = ...
97
98
def __init__ (
98
99
self ,
99
- max_length : Optional [ int ] = ...,
100
- min_length : Optional [ int ] = ...,
101
- pattern : Optional [ str ] = ...,
102
- format : Optional [ Any ] = ...,
100
+ max_length : int | None = ...,
101
+ min_length : int | None = ...,
102
+ pattern : str | None = ...,
103
+ format : Any | None = ...,
103
104
** kwargs : Any
104
105
) -> None : ...
105
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
106
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
106
107
107
108
class Boolean (Schema ):
108
- errors : List [Error ] = ...
109
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
109
+ errors : list [Error ] = ...
110
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
110
111
111
112
class Null (Schema ):
112
- errors : List [Error ] = ...
113
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
113
+ errors : list [Error ] = ...
114
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
114
115
115
116
class Enum (Schema ):
116
- errors : List [Error ] = ...
117
+ errors : list [Error ] = ...
117
118
enum : Any = ...
118
119
exact : Any = ...
119
120
def __init__ (self , enum : Any , ** kwargs : Any ) -> None : ...
120
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
121
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
121
122
122
123
class Anything (Schema ):
123
- errors : List [Error ] = ...
124
+ errors : list [Error ] = ...
124
125
types : Any = ...
125
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
126
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
126
127
127
128
class Union (Schema ):
128
- errors : List [Error ] = ...
129
- children : List [Schema ] = ...
130
- def __init__ (self , children : List [Schema ], ** kwargs : Any ) -> None : ...
131
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
129
+ errors : list [Error ] = ...
130
+ children : list [Schema ] = ...
131
+ def __init__ (self , children : list [Schema ], ** kwargs : Any ) -> None : ...
132
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
132
133
133
134
class Intersection (Schema ):
134
- children : List [Schema ] = ...
135
- def __init__ (self , children : List [Schema ], ** kwargs : Any ) -> None : ...
136
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
135
+ children : list [Schema ] = ...
136
+ def __init__ (self , children : list [Schema ], ** kwargs : Any ) -> None : ...
137
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
137
138
138
139
class ExclusiveUnion (Schema ):
139
- errors : List [Error ] = ...
140
- children : List [Schema ] = ...
141
- def __init__ (self , children : List [Schema ], ** kwargs : Any ) -> None : ...
142
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
140
+ errors : list [Error ] = ...
141
+ children : list [Schema ] = ...
142
+ def __init__ (self , children : list [Schema ], ** kwargs : Any ) -> None : ...
143
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
143
144
144
145
class Not (Schema ):
145
- errors : List [Error ] = ...
146
+ errors : list [Error ] = ...
146
147
child : Any = ...
147
148
def __init__ (self , child : Any , ** kwargs : Any ) -> None : ...
148
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
149
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
149
150
150
151
class Ref (Schema ):
151
152
ref_name : Any = ...
152
153
def __init__ (self , ref_name : Any ) -> None : ...
153
154
def dereference (self , context : Any ) -> Any : ...
154
- def validate (self , value : Any , context : Optional [ Any ] = ...) -> List [Error ]: ...
155
+ def validate (self , value : Any , context : Any | None = ...) -> list [Error ]: ...
155
156
156
157
class RefSpace (Schema ):
157
158
refs : Any = ...
158
159
root : Any = ...
159
160
root_validator : Any = ...
160
161
def __init__ (self , refs : Any , root : Any ) -> None : ...
161
- def validate (self , value : Any ) -> List [Error ]: ...
162
+ def validate (self , value : Any ) -> list [Error ]: ...
0 commit comments