1
1
import decimal
2
2
import sys
3
- from typing import Any , Callable , Generic , TypeVar
3
+ from typing import Any , Callable , Generic , Type , TypeVar
4
4
5
- from pydantic_core import ErrorDetails , InitErrorDetails
5
+ from pydantic_core import ErrorDetails , ErrorTypeInfo , InitErrorDetails , MultiHostHost
6
6
from pydantic_core .core_schema import CoreConfig , CoreSchema , ErrorType
7
7
8
- if sys .version_info < (3 , 9 ):
9
- from typing_extensions import TypedDict
8
+ if sys .version_info < (3 , 8 ):
9
+ from typing_extensions import final
10
10
else :
11
- from typing import TypedDict
11
+ from typing import final
12
12
13
13
if sys .version_info < (3 , 11 ):
14
- from typing_extensions import Literal , LiteralString , NotRequired , TypeAlias
14
+ from typing_extensions import Literal , LiteralString , Self , TypeAlias
15
15
else :
16
- from typing import Literal , LiteralString , NotRequired , TypeAlias
16
+ from typing import Literal , LiteralString , Self , TypeAlias
17
17
18
18
from _typeshed import SupportsAllComparisons
19
19
20
- __all__ = (
20
+ __all__ = [
21
21
'__version__' ,
22
22
'build_profile' ,
23
+ 'ArgsKwargs' ,
23
24
'SchemaValidator' ,
24
25
'SchemaSerializer' ,
25
26
'Url' ,
@@ -30,19 +31,29 @@ __all__ = (
30
31
'PydanticKnownError' ,
31
32
'PydanticOmit' ,
32
33
'PydanticSerializationError' ,
34
+ 'PydanticSerializationUnexpectedValue' ,
35
+ 'PydanticUndefined' ,
36
+ 'PydanticUndefinedType' ,
37
+ 'Some' ,
38
+ 'to_json' ,
39
+ 'to_jsonable_python' ,
33
40
'list_all_errors' ,
34
- )
41
+ ]
35
42
__version__ : str
36
43
build_profile : str
37
44
38
- T = TypeVar ('T ' , default = Any , covariant = True )
45
+ _T = TypeVar ('_T ' , default = Any , covariant = True )
39
46
40
- class Some (Generic [T ]):
47
+ @final
48
+ class Some (Generic [_T ]):
41
49
__match_args__ = ('value' ,)
42
50
43
51
@property
44
- def value (self ) -> T : ...
52
+ def value (self ) -> _T : ...
53
+ @classmethod
54
+ def __class_getitem__ (cls , item : Any ) -> Type [Self ]: ...
45
55
56
+ @final
46
57
class SchemaValidator :
47
58
def __init__ (self , schema : CoreSchema , config : 'CoreConfig | None' = None ) -> None : ...
48
59
@property
@@ -85,17 +96,18 @@ class SchemaValidator:
85
96
) -> 'dict[str, Any]' : ...
86
97
def get_default_value (self , * , strict : 'bool | None' = None , context : Any = None ) -> Some | None : ...
87
98
88
- IncEx : TypeAlias = 'set[int] | set[str] | dict[int, IncEx ] | dict[str, IncEx ] | None'
99
+ _IncEx : TypeAlias = 'set[int] | set[str] | dict[int, _IncEx ] | dict[str, _IncEx ] | None'
89
100
101
+ @final
90
102
class SchemaSerializer :
91
103
def __init__ (self , schema : CoreSchema , config : 'CoreConfig | None' = None ) -> None : ...
92
104
def to_python (
93
105
self ,
94
106
value : Any ,
95
107
* ,
96
108
mode : str | None = None ,
97
- include : IncEx = None ,
98
- exclude : IncEx = None ,
109
+ include : _IncEx = None ,
110
+ exclude : _IncEx = None ,
99
111
by_alias : bool = True ,
100
112
exclude_unset : bool = False ,
101
113
exclude_defaults : bool = False ,
@@ -109,8 +121,8 @@ class SchemaSerializer:
109
121
value : Any ,
110
122
* ,
111
123
indent : int | None = None ,
112
- include : IncEx = None ,
113
- exclude : IncEx = None ,
124
+ include : _IncEx = None ,
125
+ exclude : _IncEx = None ,
114
126
by_alias : bool = True ,
115
127
exclude_unset : bool = False ,
116
128
exclude_defaults : bool = False ,
@@ -124,8 +136,8 @@ def to_json(
124
136
value : Any ,
125
137
* ,
126
138
indent : int | None = None ,
127
- include : IncEx = None ,
128
- exclude : IncEx = None ,
139
+ include : _IncEx = None ,
140
+ exclude : _IncEx = None ,
129
141
by_alias : bool = True ,
130
142
exclude_none : bool = False ,
131
143
round_trip : bool = False ,
@@ -137,8 +149,8 @@ def to_json(
137
149
def to_jsonable_python (
138
150
value : Any ,
139
151
* ,
140
- include : IncEx = None ,
141
- exclude : IncEx = None ,
152
+ include : _IncEx = None ,
153
+ exclude : _IncEx = None ,
142
154
by_alias : bool = True ,
143
155
exclude_none : bool = False ,
144
156
round_trip : bool = False ,
@@ -171,12 +183,7 @@ class Url(SupportsAllComparisons):
171
183
def unicode_string (self ) -> str : ...
172
184
def __repr__ (self ) -> str : ...
173
185
def __str__ (self ) -> str : ...
174
-
175
- class MultiHostHost (TypedDict ):
176
- username : 'str | None'
177
- password : 'str | None'
178
- host : 'str | None'
179
- port : 'int | None'
186
+ def __deepcopy__ (self , memo : dict ) -> str : ...
180
187
181
188
class MultiHostUrl (SupportsAllComparisons ):
182
189
def __init__ (self , url : str ) -> None : ...
@@ -193,16 +200,19 @@ class MultiHostUrl(SupportsAllComparisons):
193
200
def unicode_string (self ) -> str : ...
194
201
def __repr__ (self ) -> str : ...
195
202
def __str__ (self ) -> str : ...
203
+ def __deepcopy__ (self , memo : dict ) -> Self : ...
196
204
205
+ @final
197
206
class SchemaError (Exception ):
198
207
def error_count (self ) -> int : ...
199
208
def errors (self ) -> 'list[ErrorDetails]' : ...
200
209
210
+ @final
201
211
class ValidationError (ValueError ):
202
212
@staticmethod
203
213
def from_exception_data (
204
214
title : str ,
205
- errors : 'list[InitErrorDetails]' ,
215
+ line_errors : 'list[InitErrorDetails]' ,
206
216
error_mode : Literal ['python' , 'json' ] = 'python' ,
207
217
hide_input : bool = False ,
208
218
) -> ValidationError :
@@ -218,6 +228,7 @@ class ValidationError(ValueError):
218
228
def errors (self , * , include_url : bool = True , include_context : bool = True ) -> 'list[ErrorDetails]' : ...
219
229
def json (self , * , indent : 'int | None' = None , include_url : bool = True , include_context : bool = True ) -> str : ...
220
230
231
+ @final
221
232
class PydanticCustomError (ValueError ):
222
233
def __init__ (
223
234
self , error_type : LiteralString , message_template : LiteralString , context : 'dict[str, Any] | None' = None
@@ -230,6 +241,7 @@ class PydanticCustomError(ValueError):
230
241
def message_template (self ) -> str : ...
231
242
def message (self ) -> str : ...
232
243
244
+ @final
233
245
class PydanticKnownError (ValueError ):
234
246
def __init__ (
235
247
self , error_type : ErrorType , context : 'dict[str, str | int | float | decimal.Decimal] | None' = None
@@ -242,31 +254,30 @@ class PydanticKnownError(ValueError):
242
254
def message_template (self ) -> str : ...
243
255
def message (self ) -> str : ...
244
256
257
+ @final
245
258
class PydanticOmit (Exception ):
246
259
def __init__ (self ) -> None : ...
247
260
261
+ @final
248
262
class PydanticSerializationError (ValueError ):
249
263
def __init__ (self , message : str ) -> None : ...
250
264
265
+ @final
251
266
class PydanticSerializationUnexpectedValue (ValueError ):
252
267
def __init__ (self , message : 'str | None' = None ) -> None : ...
253
268
254
- class ErrorTypeInfo (TypedDict ):
255
- type : ErrorType
256
- message_template_python : str
257
- example_message_python : str
258
- message_template_json : NotRequired [str ]
259
- example_message_json : NotRequired [str ]
260
- example_context : 'dict[str, str | int | float] | None'
261
-
269
+ @final
262
270
class ArgsKwargs :
263
271
def __init__ (self , args : 'tuple[Any, ...]' , kwargs : 'dict[str, Any] | None' = None ) -> None : ...
264
272
@property
265
273
def args (self ) -> 'tuple[Any, ...]' : ...
266
274
@property
267
275
def kwargs (self ) -> 'dict[str, Any] | None' : ...
268
276
269
- class PydanticUndefinedType : ...
277
+ @final
278
+ class PydanticUndefinedType :
279
+ def __copy__ (self ) -> Self : ...
280
+ def __deepcopy__ (self , memo : Any ) -> Self : ...
270
281
271
282
PydanticUndefined : PydanticUndefinedType
272
283
0 commit comments