applied-ai-018 commited on
Commit
d828db7
·
verified ·
1 Parent(s): 35c2f47

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. ckpts/universal/global_step40/zero/18.mlp.dense_h_to_4h_swiglu.weight/exp_avg_sq.pt +3 -0
  2. ckpts/universal/global_step40/zero/18.mlp.dense_h_to_4h_swiglu.weight/fp32.pt +3 -0
  3. ckpts/universal/global_step40/zero/4.attention.query_key_value.weight/exp_avg_sq.pt +3 -0
  4. venv/lib/python3.10/site-packages/__pycache__/__editable___lm_eval_0_4_2_finder.cpython-310.pyc +0 -0
  5. venv/lib/python3.10/site-packages/__pycache__/isympy.cpython-310.pyc +0 -0
  6. venv/lib/python3.10/site-packages/__pycache__/six.cpython-310.pyc +0 -0
  7. venv/lib/python3.10/site-packages/__pycache__/sqlitedict.cpython-310.pyc +0 -0
  8. venv/lib/python3.10/site-packages/__pycache__/threadpoolctl.cpython-310.pyc +0 -0
  9. venv/lib/python3.10/site-packages/__pycache__/typing_extensions.cpython-310.pyc +0 -0
  10. venv/lib/python3.10/site-packages/numpy.libs/libquadmath-96973f99.so.0.0.0 +0 -0
  11. venv/lib/python3.10/site-packages/pydantic/__init__.py +400 -0
  12. venv/lib/python3.10/site-packages/pydantic/__pycache__/__init__.cpython-310.pyc +0 -0
  13. venv/lib/python3.10/site-packages/pydantic/__pycache__/_migration.cpython-310.pyc +0 -0
  14. venv/lib/python3.10/site-packages/pydantic/__pycache__/alias_generators.cpython-310.pyc +0 -0
  15. venv/lib/python3.10/site-packages/pydantic/__pycache__/aliases.cpython-310.pyc +0 -0
  16. venv/lib/python3.10/site-packages/pydantic/__pycache__/annotated_handlers.cpython-310.pyc +0 -0
  17. venv/lib/python3.10/site-packages/pydantic/__pycache__/class_validators.cpython-310.pyc +0 -0
  18. venv/lib/python3.10/site-packages/pydantic/__pycache__/color.cpython-310.pyc +0 -0
  19. venv/lib/python3.10/site-packages/pydantic/__pycache__/config.cpython-310.pyc +0 -0
  20. venv/lib/python3.10/site-packages/pydantic/__pycache__/dataclasses.cpython-310.pyc +0 -0
  21. venv/lib/python3.10/site-packages/pydantic/__pycache__/datetime_parse.cpython-310.pyc +0 -0
  22. venv/lib/python3.10/site-packages/pydantic/__pycache__/env_settings.cpython-310.pyc +0 -0
  23. venv/lib/python3.10/site-packages/pydantic/__pycache__/error_wrappers.cpython-310.pyc +0 -0
  24. venv/lib/python3.10/site-packages/pydantic/__pycache__/errors.cpython-310.pyc +0 -0
  25. venv/lib/python3.10/site-packages/pydantic/__pycache__/fields.cpython-310.pyc +0 -0
  26. venv/lib/python3.10/site-packages/pydantic/__pycache__/functional_serializers.cpython-310.pyc +0 -0
  27. venv/lib/python3.10/site-packages/pydantic/__pycache__/functional_validators.cpython-310.pyc +0 -0
  28. venv/lib/python3.10/site-packages/pydantic/__pycache__/generics.cpython-310.pyc +0 -0
  29. venv/lib/python3.10/site-packages/pydantic/__pycache__/json.cpython-310.pyc +0 -0
  30. venv/lib/python3.10/site-packages/pydantic/__pycache__/json_schema.cpython-310.pyc +0 -0
  31. venv/lib/python3.10/site-packages/pydantic/__pycache__/mypy.cpython-310.pyc +0 -0
  32. venv/lib/python3.10/site-packages/pydantic/__pycache__/networks.cpython-310.pyc +0 -0
  33. venv/lib/python3.10/site-packages/pydantic/__pycache__/parse.cpython-310.pyc +0 -0
  34. venv/lib/python3.10/site-packages/pydantic/__pycache__/root_model.cpython-310.pyc +0 -0
  35. venv/lib/python3.10/site-packages/pydantic/__pycache__/schema.cpython-310.pyc +0 -0
  36. venv/lib/python3.10/site-packages/pydantic/__pycache__/tools.cpython-310.pyc +0 -0
  37. venv/lib/python3.10/site-packages/pydantic/__pycache__/types.cpython-310.pyc +0 -0
  38. venv/lib/python3.10/site-packages/pydantic/__pycache__/typing.cpython-310.pyc +0 -0
  39. venv/lib/python3.10/site-packages/pydantic/__pycache__/utils.cpython-310.pyc +0 -0
  40. venv/lib/python3.10/site-packages/pydantic/__pycache__/validate_call_decorator.cpython-310.pyc +0 -0
  41. venv/lib/python3.10/site-packages/pydantic/__pycache__/validators.cpython-310.pyc +0 -0
  42. venv/lib/python3.10/site-packages/pydantic/__pycache__/version.cpython-310.pyc +0 -0
  43. venv/lib/python3.10/site-packages/pydantic/__pycache__/warnings.cpython-310.pyc +0 -0
  44. venv/lib/python3.10/site-packages/pydantic/_migration.py +308 -0
  45. venv/lib/python3.10/site-packages/pydantic/alias_generators.py +50 -0
  46. venv/lib/python3.10/site-packages/pydantic/aliases.py +131 -0
  47. venv/lib/python3.10/site-packages/pydantic/annotated_handlers.py +120 -0
  48. venv/lib/python3.10/site-packages/pydantic/class_validators.py +4 -0
  49. venv/lib/python3.10/site-packages/pydantic/color.py +603 -0
  50. venv/lib/python3.10/site-packages/pydantic/config.py +1003 -0
ckpts/universal/global_step40/zero/18.mlp.dense_h_to_4h_swiglu.weight/exp_avg_sq.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7daeb05f2108583059f06c773407e45d3127b2cc8fb034af671fcaa23d5af3a7
3
+ size 33555627
ckpts/universal/global_step40/zero/18.mlp.dense_h_to_4h_swiglu.weight/fp32.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ad139000d9de29cc3a4a3a97941d0e8696bda1f464c744a140168c3c0f9acd2
3
+ size 33555533
ckpts/universal/global_step40/zero/4.attention.query_key_value.weight/exp_avg_sq.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fcb850c6c2a9a94952078771e93da0384ef661a5745b6fdbc9e597189563de75
3
+ size 50332843
venv/lib/python3.10/site-packages/__pycache__/__editable___lm_eval_0_4_2_finder.cpython-310.pyc ADDED
Binary file (19.4 kB). View file
 
venv/lib/python3.10/site-packages/__pycache__/isympy.cpython-310.pyc ADDED
Binary file (9.43 kB). View file
 
venv/lib/python3.10/site-packages/__pycache__/six.cpython-310.pyc ADDED
Binary file (27.6 kB). View file
 
venv/lib/python3.10/site-packages/__pycache__/sqlitedict.cpython-310.pyc ADDED
Binary file (18.8 kB). View file
 
venv/lib/python3.10/site-packages/__pycache__/threadpoolctl.cpython-310.pyc ADDED
Binary file (42.8 kB). View file
 
venv/lib/python3.10/site-packages/__pycache__/typing_extensions.cpython-310.pyc ADDED
Binary file (93.6 kB). View file
 
venv/lib/python3.10/site-packages/numpy.libs/libquadmath-96973f99.so.0.0.0 ADDED
Binary file (248 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__init__.py ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import typing
2
+
3
+ from ._migration import getattr_migration
4
+ from .version import VERSION
5
+
6
+ if typing.TYPE_CHECKING:
7
+ # import of virtually everything is supported via `__getattr__` below,
8
+ # but we need them here for type checking and IDE support
9
+ import pydantic_core
10
+ from pydantic_core.core_schema import (
11
+ FieldSerializationInfo,
12
+ SerializationInfo,
13
+ SerializerFunctionWrapHandler,
14
+ ValidationInfo,
15
+ ValidatorFunctionWrapHandler,
16
+ )
17
+
18
+ from . import dataclasses
19
+ from ._internal._generate_schema import GenerateSchema as GenerateSchema
20
+ from .aliases import AliasChoices, AliasGenerator, AliasPath
21
+ from .annotated_handlers import GetCoreSchemaHandler, GetJsonSchemaHandler
22
+ from .config import ConfigDict, with_config
23
+ from .errors import *
24
+ from .fields import Field, PrivateAttr, computed_field
25
+ from .functional_serializers import (
26
+ PlainSerializer,
27
+ SerializeAsAny,
28
+ WrapSerializer,
29
+ field_serializer,
30
+ model_serializer,
31
+ )
32
+ from .functional_validators import (
33
+ AfterValidator,
34
+ BeforeValidator,
35
+ InstanceOf,
36
+ PlainValidator,
37
+ SkipValidation,
38
+ WrapValidator,
39
+ field_validator,
40
+ model_validator,
41
+ )
42
+ from .json_schema import WithJsonSchema
43
+ from .main import *
44
+ from .networks import *
45
+ from .type_adapter import TypeAdapter
46
+ from .types import *
47
+ from .validate_call_decorator import validate_call
48
+ from .warnings import PydanticDeprecatedSince20, PydanticDeprecatedSince26, PydanticDeprecationWarning
49
+
50
+ # this encourages pycharm to import `ValidationError` from here, not pydantic_core
51
+ ValidationError = pydantic_core.ValidationError
52
+ from .deprecated.class_validators import root_validator, validator
53
+ from .deprecated.config import BaseConfig, Extra
54
+ from .deprecated.tools import *
55
+ from .root_model import RootModel
56
+
57
+ __version__ = VERSION
58
+ __all__ = (
59
+ # dataclasses
60
+ 'dataclasses',
61
+ # functional validators
62
+ 'field_validator',
63
+ 'model_validator',
64
+ 'AfterValidator',
65
+ 'BeforeValidator',
66
+ 'PlainValidator',
67
+ 'WrapValidator',
68
+ 'SkipValidation',
69
+ 'InstanceOf',
70
+ # JSON Schema
71
+ 'WithJsonSchema',
72
+ # deprecated V1 functional validators, these are imported via `__getattr__` below
73
+ 'root_validator',
74
+ 'validator',
75
+ # functional serializers
76
+ 'field_serializer',
77
+ 'model_serializer',
78
+ 'PlainSerializer',
79
+ 'SerializeAsAny',
80
+ 'WrapSerializer',
81
+ # config
82
+ 'ConfigDict',
83
+ 'with_config',
84
+ # deprecated V1 config, these are imported via `__getattr__` below
85
+ 'BaseConfig',
86
+ 'Extra',
87
+ # validate_call
88
+ 'validate_call',
89
+ # errors
90
+ 'PydanticErrorCodes',
91
+ 'PydanticUserError',
92
+ 'PydanticSchemaGenerationError',
93
+ 'PydanticImportError',
94
+ 'PydanticUndefinedAnnotation',
95
+ 'PydanticInvalidForJsonSchema',
96
+ # fields
97
+ 'Field',
98
+ 'computed_field',
99
+ 'PrivateAttr',
100
+ # alias
101
+ 'AliasChoices',
102
+ 'AliasGenerator',
103
+ 'AliasPath',
104
+ # main
105
+ 'BaseModel',
106
+ 'create_model',
107
+ # network
108
+ 'AnyUrl',
109
+ 'AnyHttpUrl',
110
+ 'FileUrl',
111
+ 'HttpUrl',
112
+ 'FtpUrl',
113
+ 'WebsocketUrl',
114
+ 'AnyWebsocketUrl',
115
+ 'UrlConstraints',
116
+ 'EmailStr',
117
+ 'NameEmail',
118
+ 'IPvAnyAddress',
119
+ 'IPvAnyInterface',
120
+ 'IPvAnyNetwork',
121
+ 'PostgresDsn',
122
+ 'CockroachDsn',
123
+ 'AmqpDsn',
124
+ 'RedisDsn',
125
+ 'MongoDsn',
126
+ 'KafkaDsn',
127
+ 'NatsDsn',
128
+ 'MySQLDsn',
129
+ 'MariaDBDsn',
130
+ 'ClickHouseDsn',
131
+ 'validate_email',
132
+ # root_model
133
+ 'RootModel',
134
+ # deprecated tools, these are imported via `__getattr__` below
135
+ 'parse_obj_as',
136
+ 'schema_of',
137
+ 'schema_json_of',
138
+ # types
139
+ 'Strict',
140
+ 'StrictStr',
141
+ 'conbytes',
142
+ 'conlist',
143
+ 'conset',
144
+ 'confrozenset',
145
+ 'constr',
146
+ 'StringConstraints',
147
+ 'ImportString',
148
+ 'conint',
149
+ 'PositiveInt',
150
+ 'NegativeInt',
151
+ 'NonNegativeInt',
152
+ 'NonPositiveInt',
153
+ 'confloat',
154
+ 'PositiveFloat',
155
+ 'NegativeFloat',
156
+ 'NonNegativeFloat',
157
+ 'NonPositiveFloat',
158
+ 'FiniteFloat',
159
+ 'condecimal',
160
+ 'condate',
161
+ 'UUID1',
162
+ 'UUID3',
163
+ 'UUID4',
164
+ 'UUID5',
165
+ 'FilePath',
166
+ 'DirectoryPath',
167
+ 'NewPath',
168
+ 'Json',
169
+ 'Secret',
170
+ 'SecretStr',
171
+ 'SecretBytes',
172
+ 'StrictBool',
173
+ 'StrictBytes',
174
+ 'StrictInt',
175
+ 'StrictFloat',
176
+ 'PaymentCardNumber',
177
+ 'ByteSize',
178
+ 'PastDate',
179
+ 'FutureDate',
180
+ 'PastDatetime',
181
+ 'FutureDatetime',
182
+ 'AwareDatetime',
183
+ 'NaiveDatetime',
184
+ 'AllowInfNan',
185
+ 'EncoderProtocol',
186
+ 'EncodedBytes',
187
+ 'EncodedStr',
188
+ 'Base64Encoder',
189
+ 'Base64Bytes',
190
+ 'Base64Str',
191
+ 'Base64UrlBytes',
192
+ 'Base64UrlStr',
193
+ 'GetPydanticSchema',
194
+ 'Tag',
195
+ 'Discriminator',
196
+ 'JsonValue',
197
+ # type_adapter
198
+ 'TypeAdapter',
199
+ # version
200
+ '__version__',
201
+ 'VERSION',
202
+ # warnings
203
+ 'PydanticDeprecatedSince20',
204
+ 'PydanticDeprecatedSince26',
205
+ 'PydanticDeprecationWarning',
206
+ # annotated handlers
207
+ 'GetCoreSchemaHandler',
208
+ 'GetJsonSchemaHandler',
209
+ # generate schema from ._internal
210
+ 'GenerateSchema',
211
+ # pydantic_core
212
+ 'ValidationError',
213
+ 'ValidationInfo',
214
+ 'SerializationInfo',
215
+ 'ValidatorFunctionWrapHandler',
216
+ 'FieldSerializationInfo',
217
+ 'SerializerFunctionWrapHandler',
218
+ 'OnErrorOmit',
219
+ )
220
+
221
+ # A mapping of {<member name>: (package, <module name>)} defining dynamic imports
222
+ _dynamic_imports: 'dict[str, tuple[str, str]]' = {
223
+ 'dataclasses': (__package__, '__module__'),
224
+ # functional validators
225
+ 'field_validator': (__package__, '.functional_validators'),
226
+ 'model_validator': (__package__, '.functional_validators'),
227
+ 'AfterValidator': (__package__, '.functional_validators'),
228
+ 'BeforeValidator': (__package__, '.functional_validators'),
229
+ 'PlainValidator': (__package__, '.functional_validators'),
230
+ 'WrapValidator': (__package__, '.functional_validators'),
231
+ 'SkipValidation': (__package__, '.functional_validators'),
232
+ 'InstanceOf': (__package__, '.functional_validators'),
233
+ # JSON Schema
234
+ 'WithJsonSchema': (__package__, '.json_schema'),
235
+ # functional serializers
236
+ 'field_serializer': (__package__, '.functional_serializers'),
237
+ 'model_serializer': (__package__, '.functional_serializers'),
238
+ 'PlainSerializer': (__package__, '.functional_serializers'),
239
+ 'SerializeAsAny': (__package__, '.functional_serializers'),
240
+ 'WrapSerializer': (__package__, '.functional_serializers'),
241
+ # config
242
+ 'ConfigDict': (__package__, '.config'),
243
+ 'with_config': (__package__, '.config'),
244
+ # validate call
245
+ 'validate_call': (__package__, '.validate_call_decorator'),
246
+ # errors
247
+ 'PydanticErrorCodes': (__package__, '.errors'),
248
+ 'PydanticUserError': (__package__, '.errors'),
249
+ 'PydanticSchemaGenerationError': (__package__, '.errors'),
250
+ 'PydanticImportError': (__package__, '.errors'),
251
+ 'PydanticUndefinedAnnotation': (__package__, '.errors'),
252
+ 'PydanticInvalidForJsonSchema': (__package__, '.errors'),
253
+ # fields
254
+ 'Field': (__package__, '.fields'),
255
+ 'computed_field': (__package__, '.fields'),
256
+ 'PrivateAttr': (__package__, '.fields'),
257
+ # alias
258
+ 'AliasChoices': (__package__, '.aliases'),
259
+ 'AliasGenerator': (__package__, '.aliases'),
260
+ 'AliasPath': (__package__, '.aliases'),
261
+ # main
262
+ 'BaseModel': (__package__, '.main'),
263
+ 'create_model': (__package__, '.main'),
264
+ # network
265
+ 'AnyUrl': (__package__, '.networks'),
266
+ 'AnyHttpUrl': (__package__, '.networks'),
267
+ 'FileUrl': (__package__, '.networks'),
268
+ 'HttpUrl': (__package__, '.networks'),
269
+ 'FtpUrl': (__package__, '.networks'),
270
+ 'WebsocketUrl': (__package__, '.networks'),
271
+ 'AnyWebsocketUrl': (__package__, '.networks'),
272
+ 'UrlConstraints': (__package__, '.networks'),
273
+ 'EmailStr': (__package__, '.networks'),
274
+ 'NameEmail': (__package__, '.networks'),
275
+ 'IPvAnyAddress': (__package__, '.networks'),
276
+ 'IPvAnyInterface': (__package__, '.networks'),
277
+ 'IPvAnyNetwork': (__package__, '.networks'),
278
+ 'PostgresDsn': (__package__, '.networks'),
279
+ 'CockroachDsn': (__package__, '.networks'),
280
+ 'AmqpDsn': (__package__, '.networks'),
281
+ 'RedisDsn': (__package__, '.networks'),
282
+ 'MongoDsn': (__package__, '.networks'),
283
+ 'KafkaDsn': (__package__, '.networks'),
284
+ 'NatsDsn': (__package__, '.networks'),
285
+ 'MySQLDsn': (__package__, '.networks'),
286
+ 'MariaDBDsn': (__package__, '.networks'),
287
+ 'ClickHouseDsn': (__package__, '.networks'),
288
+ 'validate_email': (__package__, '.networks'),
289
+ # root_model
290
+ 'RootModel': (__package__, '.root_model'),
291
+ # types
292
+ 'Strict': (__package__, '.types'),
293
+ 'StrictStr': (__package__, '.types'),
294
+ 'conbytes': (__package__, '.types'),
295
+ 'conlist': (__package__, '.types'),
296
+ 'conset': (__package__, '.types'),
297
+ 'confrozenset': (__package__, '.types'),
298
+ 'constr': (__package__, '.types'),
299
+ 'StringConstraints': (__package__, '.types'),
300
+ 'ImportString': (__package__, '.types'),
301
+ 'conint': (__package__, '.types'),
302
+ 'PositiveInt': (__package__, '.types'),
303
+ 'NegativeInt': (__package__, '.types'),
304
+ 'NonNegativeInt': (__package__, '.types'),
305
+ 'NonPositiveInt': (__package__, '.types'),
306
+ 'confloat': (__package__, '.types'),
307
+ 'PositiveFloat': (__package__, '.types'),
308
+ 'NegativeFloat': (__package__, '.types'),
309
+ 'NonNegativeFloat': (__package__, '.types'),
310
+ 'NonPositiveFloat': (__package__, '.types'),
311
+ 'FiniteFloat': (__package__, '.types'),
312
+ 'condecimal': (__package__, '.types'),
313
+ 'condate': (__package__, '.types'),
314
+ 'UUID1': (__package__, '.types'),
315
+ 'UUID3': (__package__, '.types'),
316
+ 'UUID4': (__package__, '.types'),
317
+ 'UUID5': (__package__, '.types'),
318
+ 'FilePath': (__package__, '.types'),
319
+ 'DirectoryPath': (__package__, '.types'),
320
+ 'NewPath': (__package__, '.types'),
321
+ 'Json': (__package__, '.types'),
322
+ 'Secret': (__package__, '.types'),
323
+ 'SecretStr': (__package__, '.types'),
324
+ 'SecretBytes': (__package__, '.types'),
325
+ 'StrictBool': (__package__, '.types'),
326
+ 'StrictBytes': (__package__, '.types'),
327
+ 'StrictInt': (__package__, '.types'),
328
+ 'StrictFloat': (__package__, '.types'),
329
+ 'PaymentCardNumber': (__package__, '.types'),
330
+ 'ByteSize': (__package__, '.types'),
331
+ 'PastDate': (__package__, '.types'),
332
+ 'FutureDate': (__package__, '.types'),
333
+ 'PastDatetime': (__package__, '.types'),
334
+ 'FutureDatetime': (__package__, '.types'),
335
+ 'AwareDatetime': (__package__, '.types'),
336
+ 'NaiveDatetime': (__package__, '.types'),
337
+ 'AllowInfNan': (__package__, '.types'),
338
+ 'EncoderProtocol': (__package__, '.types'),
339
+ 'EncodedBytes': (__package__, '.types'),
340
+ 'EncodedStr': (__package__, '.types'),
341
+ 'Base64Encoder': (__package__, '.types'),
342
+ 'Base64Bytes': (__package__, '.types'),
343
+ 'Base64Str': (__package__, '.types'),
344
+ 'Base64UrlBytes': (__package__, '.types'),
345
+ 'Base64UrlStr': (__package__, '.types'),
346
+ 'GetPydanticSchema': (__package__, '.types'),
347
+ 'Tag': (__package__, '.types'),
348
+ 'Discriminator': (__package__, '.types'),
349
+ 'JsonValue': (__package__, '.types'),
350
+ 'OnErrorOmit': (__package__, '.types'),
351
+ # type_adapter
352
+ 'TypeAdapter': (__package__, '.type_adapter'),
353
+ # warnings
354
+ 'PydanticDeprecatedSince20': (__package__, '.warnings'),
355
+ 'PydanticDeprecatedSince26': (__package__, '.warnings'),
356
+ 'PydanticDeprecationWarning': (__package__, '.warnings'),
357
+ # annotated handlers
358
+ 'GetCoreSchemaHandler': (__package__, '.annotated_handlers'),
359
+ 'GetJsonSchemaHandler': (__package__, '.annotated_handlers'),
360
+ # generate schema from ._internal
361
+ 'GenerateSchema': (__package__, '._internal._generate_schema'),
362
+ # pydantic_core stuff
363
+ 'ValidationError': ('pydantic_core', '.'),
364
+ 'ValidationInfo': ('pydantic_core', '.core_schema'),
365
+ 'SerializationInfo': ('pydantic_core', '.core_schema'),
366
+ 'ValidatorFunctionWrapHandler': ('pydantic_core', '.core_schema'),
367
+ 'FieldSerializationInfo': ('pydantic_core', '.core_schema'),
368
+ 'SerializerFunctionWrapHandler': ('pydantic_core', '.core_schema'),
369
+ # deprecated, mostly not included in __all__
370
+ 'root_validator': (__package__, '.deprecated.class_validators'),
371
+ 'validator': (__package__, '.deprecated.class_validators'),
372
+ 'BaseConfig': (__package__, '.deprecated.config'),
373
+ 'Extra': (__package__, '.deprecated.config'),
374
+ 'parse_obj_as': (__package__, '.deprecated.tools'),
375
+ 'schema_of': (__package__, '.deprecated.tools'),
376
+ 'schema_json_of': (__package__, '.deprecated.tools'),
377
+ 'FieldValidationInfo': ('pydantic_core', '.core_schema'),
378
+ }
379
+
380
+ _getattr_migration = getattr_migration(__name__)
381
+
382
+
383
+ def __getattr__(attr_name: str) -> object:
384
+ dynamic_attr = _dynamic_imports.get(attr_name)
385
+ if dynamic_attr is None:
386
+ return _getattr_migration(attr_name)
387
+
388
+ package, module_name = dynamic_attr
389
+
390
+ from importlib import import_module
391
+
392
+ if module_name == '__module__':
393
+ return import_module(f'.{attr_name}', package=package)
394
+ else:
395
+ module = import_module(module_name, package=package)
396
+ return getattr(module, attr_name)
397
+
398
+
399
+ def __dir__() -> 'list[str]':
400
+ return list(__all__)
venv/lib/python3.10/site-packages/pydantic/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (7.2 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/_migration.cpython-310.pyc ADDED
Binary file (10.2 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/alias_generators.cpython-310.pyc ADDED
Binary file (2.06 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/aliases.cpython-310.pyc ADDED
Binary file (5.3 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/annotated_handlers.cpython-310.pyc ADDED
Binary file (5.17 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/class_validators.cpython-310.pyc ADDED
Binary file (341 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/color.cpython-310.pyc ADDED
Binary file (22.3 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/config.cpython-310.pyc ADDED
Binary file (4.31 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/dataclasses.cpython-310.pyc ADDED
Binary file (9.79 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/datetime_parse.cpython-310.pyc ADDED
Binary file (341 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/env_settings.cpython-310.pyc ADDED
Binary file (337 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/error_wrappers.cpython-310.pyc ADDED
Binary file (341 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/errors.cpython-310.pyc ADDED
Binary file (5.37 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/fields.cpython-310.pyc ADDED
Binary file (41 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/functional_serializers.cpython-310.pyc ADDED
Binary file (13.6 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/functional_validators.cpython-310.pyc ADDED
Binary file (22.4 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/generics.cpython-310.pyc ADDED
Binary file (329 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/json.cpython-310.pyc ADDED
Binary file (321 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/json_schema.cpython-310.pyc ADDED
Binary file (80 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/mypy.cpython-310.pyc ADDED
Binary file (39 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/networks.cpython-310.pyc ADDED
Binary file (13.9 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/parse.cpython-310.pyc ADDED
Binary file (323 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/root_model.cpython-310.pyc ADDED
Binary file (6.31 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/schema.cpython-310.pyc ADDED
Binary file (325 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/tools.cpython-310.pyc ADDED
Binary file (323 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/types.cpython-310.pyc ADDED
Binary file (71.4 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/typing.cpython-310.pyc ADDED
Binary file (321 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/utils.cpython-310.pyc ADDED
Binary file (323 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/validate_call_decorator.cpython-310.pyc ADDED
Binary file (2.47 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/validators.cpython-310.pyc ADDED
Binary file (333 Bytes). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/version.cpython-310.pyc ADDED
Binary file (2.64 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/__pycache__/warnings.cpython-310.pyc ADDED
Binary file (3.14 kB). View file
 
venv/lib/python3.10/site-packages/pydantic/_migration.py ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from typing import Any, Callable, Dict
3
+
4
+ from .version import version_short
5
+
6
+ MOVED_IN_V2 = {
7
+ 'pydantic.utils:version_info': 'pydantic.version:version_info',
8
+ 'pydantic.error_wrappers:ValidationError': 'pydantic:ValidationError',
9
+ 'pydantic.utils:to_camel': 'pydantic.alias_generators:to_pascal',
10
+ 'pydantic.utils:to_lower_camel': 'pydantic.alias_generators:to_camel',
11
+ 'pydantic:PyObject': 'pydantic.types:ImportString',
12
+ 'pydantic.types:PyObject': 'pydantic.types:ImportString',
13
+ 'pydantic.generics:GenericModel': 'pydantic.BaseModel',
14
+ }
15
+
16
+ DEPRECATED_MOVED_IN_V2 = {
17
+ 'pydantic.tools:schema_of': 'pydantic.deprecated.tools:schema_of',
18
+ 'pydantic.tools:parse_obj_as': 'pydantic.deprecated.tools:parse_obj_as',
19
+ 'pydantic.tools:schema_json_of': 'pydantic.deprecated.tools:schema_json_of',
20
+ 'pydantic.json:pydantic_encoder': 'pydantic.deprecated.json:pydantic_encoder',
21
+ 'pydantic:validate_arguments': 'pydantic.deprecated.decorator:validate_arguments',
22
+ 'pydantic.json:custom_pydantic_encoder': 'pydantic.deprecated.json:custom_pydantic_encoder',
23
+ 'pydantic.json:timedelta_isoformat': 'pydantic.deprecated.json:timedelta_isoformat',
24
+ 'pydantic.decorator:validate_arguments': 'pydantic.deprecated.decorator:validate_arguments',
25
+ 'pydantic.class_validators:validator': 'pydantic.deprecated.class_validators:validator',
26
+ 'pydantic.class_validators:root_validator': 'pydantic.deprecated.class_validators:root_validator',
27
+ 'pydantic.config:BaseConfig': 'pydantic.deprecated.config:BaseConfig',
28
+ 'pydantic.config:Extra': 'pydantic.deprecated.config:Extra',
29
+ }
30
+
31
+ REDIRECT_TO_V1 = {
32
+ f'pydantic.utils:{obj}': f'pydantic.v1.utils:{obj}'
33
+ for obj in (
34
+ 'deep_update',
35
+ 'GetterDict',
36
+ 'lenient_issubclass',
37
+ 'lenient_isinstance',
38
+ 'is_valid_field',
39
+ 'update_not_none',
40
+ 'import_string',
41
+ 'Representation',
42
+ 'ROOT_KEY',
43
+ 'smart_deepcopy',
44
+ 'sequence_like',
45
+ )
46
+ }
47
+
48
+
49
+ REMOVED_IN_V2 = {
50
+ 'pydantic:ConstrainedBytes',
51
+ 'pydantic:ConstrainedDate',
52
+ 'pydantic:ConstrainedDecimal',
53
+ 'pydantic:ConstrainedFloat',
54
+ 'pydantic:ConstrainedFrozenSet',
55
+ 'pydantic:ConstrainedInt',
56
+ 'pydantic:ConstrainedList',
57
+ 'pydantic:ConstrainedSet',
58
+ 'pydantic:ConstrainedStr',
59
+ 'pydantic:JsonWrapper',
60
+ 'pydantic:NoneBytes',
61
+ 'pydantic:NoneStr',
62
+ 'pydantic:NoneStrBytes',
63
+ 'pydantic:Protocol',
64
+ 'pydantic:Required',
65
+ 'pydantic:StrBytes',
66
+ 'pydantic:compiled',
67
+ 'pydantic.config:get_config',
68
+ 'pydantic.config:inherit_config',
69
+ 'pydantic.config:prepare_config',
70
+ 'pydantic:create_model_from_namedtuple',
71
+ 'pydantic:create_model_from_typeddict',
72
+ 'pydantic.dataclasses:create_pydantic_model_from_dataclass',
73
+ 'pydantic.dataclasses:make_dataclass_validator',
74
+ 'pydantic.dataclasses:set_validation',
75
+ 'pydantic.datetime_parse:parse_date',
76
+ 'pydantic.datetime_parse:parse_time',
77
+ 'pydantic.datetime_parse:parse_datetime',
78
+ 'pydantic.datetime_parse:parse_duration',
79
+ 'pydantic.error_wrappers:ErrorWrapper',
80
+ 'pydantic.errors:AnyStrMaxLengthError',
81
+ 'pydantic.errors:AnyStrMinLengthError',
82
+ 'pydantic.errors:ArbitraryTypeError',
83
+ 'pydantic.errors:BoolError',
84
+ 'pydantic.errors:BytesError',
85
+ 'pydantic.errors:CallableError',
86
+ 'pydantic.errors:ClassError',
87
+ 'pydantic.errors:ColorError',
88
+ 'pydantic.errors:ConfigError',
89
+ 'pydantic.errors:DataclassTypeError',
90
+ 'pydantic.errors:DateError',
91
+ 'pydantic.errors:DateNotInTheFutureError',
92
+ 'pydantic.errors:DateNotInThePastError',
93
+ 'pydantic.errors:DateTimeError',
94
+ 'pydantic.errors:DecimalError',
95
+ 'pydantic.errors:DecimalIsNotFiniteError',
96
+ 'pydantic.errors:DecimalMaxDigitsError',
97
+ 'pydantic.errors:DecimalMaxPlacesError',
98
+ 'pydantic.errors:DecimalWholeDigitsError',
99
+ 'pydantic.errors:DictError',
100
+ 'pydantic.errors:DurationError',
101
+ 'pydantic.errors:EmailError',
102
+ 'pydantic.errors:EnumError',
103
+ 'pydantic.errors:EnumMemberError',
104
+ 'pydantic.errors:ExtraError',
105
+ 'pydantic.errors:FloatError',
106
+ 'pydantic.errors:FrozenSetError',
107
+ 'pydantic.errors:FrozenSetMaxLengthError',
108
+ 'pydantic.errors:FrozenSetMinLengthError',
109
+ 'pydantic.errors:HashableError',
110
+ 'pydantic.errors:IPv4AddressError',
111
+ 'pydantic.errors:IPv4InterfaceError',
112
+ 'pydantic.errors:IPv4NetworkError',
113
+ 'pydantic.errors:IPv6AddressError',
114
+ 'pydantic.errors:IPv6InterfaceError',
115
+ 'pydantic.errors:IPv6NetworkError',
116
+ 'pydantic.errors:IPvAnyAddressError',
117
+ 'pydantic.errors:IPvAnyInterfaceError',
118
+ 'pydantic.errors:IPvAnyNetworkError',
119
+ 'pydantic.errors:IntEnumError',
120
+ 'pydantic.errors:IntegerError',
121
+ 'pydantic.errors:InvalidByteSize',
122
+ 'pydantic.errors:InvalidByteSizeUnit',
123
+ 'pydantic.errors:InvalidDiscriminator',
124
+ 'pydantic.errors:InvalidLengthForBrand',
125
+ 'pydantic.errors:JsonError',
126
+ 'pydantic.errors:JsonTypeError',
127
+ 'pydantic.errors:ListError',
128
+ 'pydantic.errors:ListMaxLengthError',
129
+ 'pydantic.errors:ListMinLengthError',
130
+ 'pydantic.errors:ListUniqueItemsError',
131
+ 'pydantic.errors:LuhnValidationError',
132
+ 'pydantic.errors:MissingDiscriminator',
133
+ 'pydantic.errors:MissingError',
134
+ 'pydantic.errors:NoneIsAllowedError',
135
+ 'pydantic.errors:NoneIsNotAllowedError',
136
+ 'pydantic.errors:NotDigitError',
137
+ 'pydantic.errors:NotNoneError',
138
+ 'pydantic.errors:NumberNotGeError',
139
+ 'pydantic.errors:NumberNotGtError',
140
+ 'pydantic.errors:NumberNotLeError',
141
+ 'pydantic.errors:NumberNotLtError',
142
+ 'pydantic.errors:NumberNotMultipleError',
143
+ 'pydantic.errors:PathError',
144
+ 'pydantic.errors:PathNotADirectoryError',
145
+ 'pydantic.errors:PathNotAFileError',
146
+ 'pydantic.errors:PathNotExistsError',
147
+ 'pydantic.errors:PatternError',
148
+ 'pydantic.errors:PyObjectError',
149
+ 'pydantic.errors:PydanticTypeError',
150
+ 'pydantic.errors:PydanticValueError',
151
+ 'pydantic.errors:SequenceError',
152
+ 'pydantic.errors:SetError',
153
+ 'pydantic.errors:SetMaxLengthError',
154
+ 'pydantic.errors:SetMinLengthError',
155
+ 'pydantic.errors:StrError',
156
+ 'pydantic.errors:StrRegexError',
157
+ 'pydantic.errors:StrictBoolError',
158
+ 'pydantic.errors:SubclassError',
159
+ 'pydantic.errors:TimeError',
160
+ 'pydantic.errors:TupleError',
161
+ 'pydantic.errors:TupleLengthError',
162
+ 'pydantic.errors:UUIDError',
163
+ 'pydantic.errors:UUIDVersionError',
164
+ 'pydantic.errors:UrlError',
165
+ 'pydantic.errors:UrlExtraError',
166
+ 'pydantic.errors:UrlHostError',
167
+ 'pydantic.errors:UrlHostTldError',
168
+ 'pydantic.errors:UrlPortError',
169
+ 'pydantic.errors:UrlSchemeError',
170
+ 'pydantic.errors:UrlSchemePermittedError',
171
+ 'pydantic.errors:UrlUserInfoError',
172
+ 'pydantic.errors:WrongConstantError',
173
+ 'pydantic.main:validate_model',
174
+ 'pydantic.networks:stricturl',
175
+ 'pydantic:parse_file_as',
176
+ 'pydantic:parse_raw_as',
177
+ 'pydantic:stricturl',
178
+ 'pydantic.tools:parse_file_as',
179
+ 'pydantic.tools:parse_raw_as',
180
+ 'pydantic.types:ConstrainedBytes',
181
+ 'pydantic.types:ConstrainedDate',
182
+ 'pydantic.types:ConstrainedDecimal',
183
+ 'pydantic.types:ConstrainedFloat',
184
+ 'pydantic.types:ConstrainedFrozenSet',
185
+ 'pydantic.types:ConstrainedInt',
186
+ 'pydantic.types:ConstrainedList',
187
+ 'pydantic.types:ConstrainedSet',
188
+ 'pydantic.types:ConstrainedStr',
189
+ 'pydantic.types:JsonWrapper',
190
+ 'pydantic.types:NoneBytes',
191
+ 'pydantic.types:NoneStr',
192
+ 'pydantic.types:NoneStrBytes',
193
+ 'pydantic.types:StrBytes',
194
+ 'pydantic.typing:evaluate_forwardref',
195
+ 'pydantic.typing:AbstractSetIntStr',
196
+ 'pydantic.typing:AnyCallable',
197
+ 'pydantic.typing:AnyClassMethod',
198
+ 'pydantic.typing:CallableGenerator',
199
+ 'pydantic.typing:DictAny',
200
+ 'pydantic.typing:DictIntStrAny',
201
+ 'pydantic.typing:DictStrAny',
202
+ 'pydantic.typing:IntStr',
203
+ 'pydantic.typing:ListStr',
204
+ 'pydantic.typing:MappingIntStrAny',
205
+ 'pydantic.typing:NoArgAnyCallable',
206
+ 'pydantic.typing:NoneType',
207
+ 'pydantic.typing:ReprArgs',
208
+ 'pydantic.typing:SetStr',
209
+ 'pydantic.typing:StrPath',
210
+ 'pydantic.typing:TupleGenerator',
211
+ 'pydantic.typing:WithArgsTypes',
212
+ 'pydantic.typing:all_literal_values',
213
+ 'pydantic.typing:display_as_type',
214
+ 'pydantic.typing:get_all_type_hints',
215
+ 'pydantic.typing:get_args',
216
+ 'pydantic.typing:get_origin',
217
+ 'pydantic.typing:get_sub_types',
218
+ 'pydantic.typing:is_callable_type',
219
+ 'pydantic.typing:is_classvar',
220
+ 'pydantic.typing:is_finalvar',
221
+ 'pydantic.typing:is_literal_type',
222
+ 'pydantic.typing:is_namedtuple',
223
+ 'pydantic.typing:is_new_type',
224
+ 'pydantic.typing:is_none_type',
225
+ 'pydantic.typing:is_typeddict',
226
+ 'pydantic.typing:is_typeddict_special',
227
+ 'pydantic.typing:is_union',
228
+ 'pydantic.typing:new_type_supertype',
229
+ 'pydantic.typing:resolve_annotations',
230
+ 'pydantic.typing:typing_base',
231
+ 'pydantic.typing:update_field_forward_refs',
232
+ 'pydantic.typing:update_model_forward_refs',
233
+ 'pydantic.utils:ClassAttribute',
234
+ 'pydantic.utils:DUNDER_ATTRIBUTES',
235
+ 'pydantic.utils:PyObjectStr',
236
+ 'pydantic.utils:ValueItems',
237
+ 'pydantic.utils:almost_equal_floats',
238
+ 'pydantic.utils:get_discriminator_alias_and_values',
239
+ 'pydantic.utils:get_model',
240
+ 'pydantic.utils:get_unique_discriminator_alias',
241
+ 'pydantic.utils:in_ipython',
242
+ 'pydantic.utils:is_valid_identifier',
243
+ 'pydantic.utils:path_type',
244
+ 'pydantic.utils:validate_field_name',
245
+ 'pydantic:validate_model',
246
+ }
247
+
248
+
249
+ def getattr_migration(module: str) -> Callable[[str], Any]:
250
+ """Implement PEP 562 for objects that were either moved or removed on the migration
251
+ to V2.
252
+
253
+ Args:
254
+ module: The module name.
255
+
256
+ Returns:
257
+ A callable that will raise an error if the object is not found.
258
+ """
259
+ # This avoids circular import with errors.py.
260
+ from .errors import PydanticImportError
261
+
262
+ def wrapper(name: str) -> object:
263
+ """Raise an error if the object is not found, or warn if it was moved.
264
+
265
+ In case it was moved, it still returns the object.
266
+
267
+ Args:
268
+ name: The object name.
269
+
270
+ Returns:
271
+ The object.
272
+ """
273
+ if name == '__path__':
274
+ raise AttributeError(f'module {module!r} has no attribute {name!r}')
275
+
276
+ import warnings
277
+
278
+ from ._internal._validators import import_string
279
+
280
+ import_path = f'{module}:{name}'
281
+ if import_path in MOVED_IN_V2.keys():
282
+ new_location = MOVED_IN_V2[import_path]
283
+ warnings.warn(f'`{import_path}` has been moved to `{new_location}`.')
284
+ return import_string(MOVED_IN_V2[import_path])
285
+ if import_path in DEPRECATED_MOVED_IN_V2:
286
+ # skip the warning here because a deprecation warning will be raised elsewhere
287
+ return import_string(DEPRECATED_MOVED_IN_V2[import_path])
288
+ if import_path in REDIRECT_TO_V1:
289
+ new_location = REDIRECT_TO_V1[import_path]
290
+ warnings.warn(
291
+ f'`{import_path}` has been removed. We are importing from `{new_location}` instead.'
292
+ 'See the migration guide for more details: https://docs.pydantic.dev/latest/migration/'
293
+ )
294
+ return import_string(REDIRECT_TO_V1[import_path])
295
+ if import_path == 'pydantic:BaseSettings':
296
+ raise PydanticImportError(
297
+ '`BaseSettings` has been moved to the `pydantic-settings` package. '
298
+ f'See https://docs.pydantic.dev/{version_short()}/migration/#basesettings-has-moved-to-pydantic-settings '
299
+ 'for more details.'
300
+ )
301
+ if import_path in REMOVED_IN_V2:
302
+ raise PydanticImportError(f'`{import_path}` has been removed in V2.')
303
+ globals: Dict[str, Any] = sys.modules[module].__dict__
304
+ if name in globals:
305
+ return globals[name]
306
+ raise AttributeError(f'module {module!r} has no attribute {name!r}')
307
+
308
+ return wrapper
venv/lib/python3.10/site-packages/pydantic/alias_generators.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Alias generators for converting between different capitalization conventions."""
2
+ import re
3
+
4
+ __all__ = ('to_pascal', 'to_camel', 'to_snake')
5
+
6
+
7
+ def to_pascal(snake: str) -> str:
8
+ """Convert a snake_case string to PascalCase.
9
+
10
+ Args:
11
+ snake: The string to convert.
12
+
13
+ Returns:
14
+ The PascalCase string.
15
+ """
16
+ camel = snake.title()
17
+ return re.sub('([0-9A-Za-z])_(?=[0-9A-Z])', lambda m: m.group(1), camel)
18
+
19
+
20
+ def to_camel(snake: str) -> str:
21
+ """Convert a snake_case string to camelCase.
22
+
23
+ Args:
24
+ snake: The string to convert.
25
+
26
+ Returns:
27
+ The converted camelCase string.
28
+ """
29
+ camel = to_pascal(snake)
30
+ return re.sub('(^_*[A-Z])', lambda m: m.group(1).lower(), camel)
31
+
32
+
33
+ def to_snake(camel: str) -> str:
34
+ """Convert a PascalCase or camelCase string to snake_case.
35
+
36
+ Args:
37
+ camel: The string to convert.
38
+
39
+ Returns:
40
+ The converted string in snake_case.
41
+ """
42
+ # Handle the sequence of uppercase letters followed by a lowercase letter
43
+ snake = re.sub(r'([A-Z]+)([A-Z][a-z])', lambda m: f'{m.group(1)}_{m.group(2)}', camel)
44
+ # Insert an underscore between a lowercase letter and an uppercase letter
45
+ snake = re.sub(r'([a-z])([A-Z])', lambda m: f'{m.group(1)}_{m.group(2)}', snake)
46
+ # Insert an underscore between a digit and an uppercase letter
47
+ snake = re.sub(r'([0-9])([A-Z])', lambda m: f'{m.group(1)}_{m.group(2)}', snake)
48
+ # Insert an underscore between a lowercase letter and a digit
49
+ snake = re.sub(r'([a-z])([0-9])', lambda m: f'{m.group(1)}_{m.group(2)}', snake)
50
+ return snake.lower()
venv/lib/python3.10/site-packages/pydantic/aliases.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Support for alias configurations."""
2
+ from __future__ import annotations
3
+
4
+ import dataclasses
5
+ from typing import Any, Callable, Literal
6
+
7
+ from pydantic_core import PydanticUndefined
8
+
9
+ from ._internal import _internal_dataclass
10
+
11
+ __all__ = ('AliasGenerator', 'AliasPath', 'AliasChoices')
12
+
13
+
14
+ @dataclasses.dataclass(**_internal_dataclass.slots_true)
15
+ class AliasPath:
16
+ """Usage docs: https://docs.pydantic.dev/2.7/concepts/alias#aliaspath-and-aliaschoices
17
+
18
+ A data class used by `validation_alias` as a convenience to create aliases.
19
+
20
+ Attributes:
21
+ path: A list of string or integer aliases.
22
+ """
23
+
24
+ path: list[int | str]
25
+
26
+ def __init__(self, first_arg: str, *args: str | int) -> None:
27
+ self.path = [first_arg] + list(args)
28
+
29
+ def convert_to_aliases(self) -> list[str | int]:
30
+ """Converts arguments to a list of string or integer aliases.
31
+
32
+ Returns:
33
+ The list of aliases.
34
+ """
35
+ return self.path
36
+
37
+ def search_dict_for_path(self, d: dict) -> Any:
38
+ """Searches a dictionary for the path specified by the alias.
39
+
40
+ Returns:
41
+ The value at the specified path, or `PydanticUndefined` if the path is not found.
42
+ """
43
+ v = d
44
+ for k in self.path:
45
+ if isinstance(v, str):
46
+ # disallow indexing into a str, like for AliasPath('x', 0) and x='abc'
47
+ return PydanticUndefined
48
+ try:
49
+ v = v[k]
50
+ except (KeyError, IndexError, TypeError):
51
+ return PydanticUndefined
52
+ return v
53
+
54
+
55
+ @dataclasses.dataclass(**_internal_dataclass.slots_true)
56
+ class AliasChoices:
57
+ """Usage docs: https://docs.pydantic.dev/2.7/concepts/alias#aliaspath-and-aliaschoices
58
+
59
+ A data class used by `validation_alias` as a convenience to create aliases.
60
+
61
+ Attributes:
62
+ choices: A list containing a string or `AliasPath`.
63
+ """
64
+
65
+ choices: list[str | AliasPath]
66
+
67
+ def __init__(self, first_choice: str | AliasPath, *choices: str | AliasPath) -> None:
68
+ self.choices = [first_choice] + list(choices)
69
+
70
+ def convert_to_aliases(self) -> list[list[str | int]]:
71
+ """Converts arguments to a list of lists containing string or integer aliases.
72
+
73
+ Returns:
74
+ The list of aliases.
75
+ """
76
+ aliases: list[list[str | int]] = []
77
+ for c in self.choices:
78
+ if isinstance(c, AliasPath):
79
+ aliases.append(c.convert_to_aliases())
80
+ else:
81
+ aliases.append([c])
82
+ return aliases
83
+
84
+
85
+ @dataclasses.dataclass(**_internal_dataclass.slots_true)
86
+ class AliasGenerator:
87
+ """Usage docs: https://docs.pydantic.dev/2.7/concepts/alias#using-an-aliasgenerator
88
+
89
+ A data class used by `alias_generator` as a convenience to create various aliases.
90
+
91
+ Attributes:
92
+ alias: A callable that takes a field name and returns an alias for it.
93
+ validation_alias: A callable that takes a field name and returns a validation alias for it.
94
+ serialization_alias: A callable that takes a field name and returns a serialization alias for it.
95
+ """
96
+
97
+ alias: Callable[[str], str] | None = None
98
+ validation_alias: Callable[[str], str | AliasPath | AliasChoices] | None = None
99
+ serialization_alias: Callable[[str], str] | None = None
100
+
101
+ def _generate_alias(
102
+ self,
103
+ alias_kind: Literal['alias', 'validation_alias', 'serialization_alias'],
104
+ allowed_types: tuple[type[str] | type[AliasPath] | type[AliasChoices], ...],
105
+ field_name: str,
106
+ ) -> str | AliasPath | AliasChoices | None:
107
+ """Generate an alias of the specified kind. Returns None if the alias generator is None.
108
+
109
+ Raises:
110
+ TypeError: If the alias generator produces an invalid type.
111
+ """
112
+ alias = None
113
+ if alias_generator := getattr(self, alias_kind):
114
+ alias = alias_generator(field_name)
115
+ if alias and not isinstance(alias, allowed_types):
116
+ raise TypeError(
117
+ f'Invalid `{alias_kind}` type. `{alias_kind}` generator must produce one of `{allowed_types}`'
118
+ )
119
+ return alias
120
+
121
+ def generate_aliases(self, field_name: str) -> tuple[str | None, str | AliasPath | AliasChoices | None, str | None]:
122
+ """Generate `alias`, `validation_alias`, and `serialization_alias` for a field.
123
+
124
+ Returns:
125
+ A tuple of three aliases - validation, alias, and serialization.
126
+ """
127
+ alias = self._generate_alias('alias', (str,), field_name)
128
+ validation_alias = self._generate_alias('validation_alias', (str, AliasChoices, AliasPath), field_name)
129
+ serialization_alias = self._generate_alias('serialization_alias', (str,), field_name)
130
+
131
+ return alias, validation_alias, serialization_alias # type: ignore
venv/lib/python3.10/site-packages/pydantic/annotated_handlers.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Type annotations to use with `__get_pydantic_core_schema__` and `__get_pydantic_json_schema__`."""
2
+ from __future__ import annotations as _annotations
3
+
4
+ from typing import TYPE_CHECKING, Any, Union
5
+
6
+ from pydantic_core import core_schema
7
+
8
+ if TYPE_CHECKING:
9
+ from .json_schema import JsonSchemaMode, JsonSchemaValue
10
+
11
+ CoreSchemaOrField = Union[
12
+ core_schema.CoreSchema,
13
+ core_schema.ModelField,
14
+ core_schema.DataclassField,
15
+ core_schema.TypedDictField,
16
+ core_schema.ComputedField,
17
+ ]
18
+
19
+ __all__ = 'GetJsonSchemaHandler', 'GetCoreSchemaHandler'
20
+
21
+
22
+ class GetJsonSchemaHandler:
23
+ """Handler to call into the next JSON schema generation function.
24
+
25
+ Attributes:
26
+ mode: Json schema mode, can be `validation` or `serialization`.
27
+ """
28
+
29
+ mode: JsonSchemaMode
30
+
31
+ def __call__(self, core_schema: CoreSchemaOrField, /) -> JsonSchemaValue:
32
+ """Call the inner handler and get the JsonSchemaValue it returns.
33
+ This will call the next JSON schema modifying function up until it calls
34
+ into `pydantic.json_schema.GenerateJsonSchema`, which will raise a
35
+ `pydantic.errors.PydanticInvalidForJsonSchema` error if it cannot generate
36
+ a JSON schema.
37
+
38
+ Args:
39
+ core_schema: A `pydantic_core.core_schema.CoreSchema`.
40
+
41
+ Returns:
42
+ JsonSchemaValue: The JSON schema generated by the inner JSON schema modify
43
+ functions.
44
+ """
45
+ raise NotImplementedError
46
+
47
+ def resolve_ref_schema(self, maybe_ref_json_schema: JsonSchemaValue, /) -> JsonSchemaValue:
48
+ """Get the real schema for a `{"$ref": ...}` schema.
49
+ If the schema given is not a `$ref` schema, it will be returned as is.
50
+ This means you don't have to check before calling this function.
51
+
52
+ Args:
53
+ maybe_ref_json_schema: A JsonSchemaValue which may be a `$ref` schema.
54
+
55
+ Raises:
56
+ LookupError: If the ref is not found.
57
+
58
+ Returns:
59
+ JsonSchemaValue: A JsonSchemaValue that has no `$ref`.
60
+ """
61
+ raise NotImplementedError
62
+
63
+
64
+ class GetCoreSchemaHandler:
65
+ """Handler to call into the next CoreSchema schema generation function."""
66
+
67
+ def __call__(self, source_type: Any, /) -> core_schema.CoreSchema:
68
+ """Call the inner handler and get the CoreSchema it returns.
69
+ This will call the next CoreSchema modifying function up until it calls
70
+ into Pydantic's internal schema generation machinery, which will raise a
71
+ `pydantic.errors.PydanticSchemaGenerationError` error if it cannot generate
72
+ a CoreSchema for the given source type.
73
+
74
+ Args:
75
+ source_type: The input type.
76
+
77
+ Returns:
78
+ CoreSchema: The `pydantic-core` CoreSchema generated.
79
+ """
80
+ raise NotImplementedError
81
+
82
+ def generate_schema(self, source_type: Any, /) -> core_schema.CoreSchema:
83
+ """Generate a schema unrelated to the current context.
84
+ Use this function if e.g. you are handling schema generation for a sequence
85
+ and want to generate a schema for its items.
86
+ Otherwise, you may end up doing something like applying a `min_length` constraint
87
+ that was intended for the sequence itself to its items!
88
+
89
+ Args:
90
+ source_type: The input type.
91
+
92
+ Returns:
93
+ CoreSchema: The `pydantic-core` CoreSchema generated.
94
+ """
95
+ raise NotImplementedError
96
+
97
+ def resolve_ref_schema(self, maybe_ref_schema: core_schema.CoreSchema, /) -> core_schema.CoreSchema:
98
+ """Get the real schema for a `definition-ref` schema.
99
+ If the schema given is not a `definition-ref` schema, it will be returned as is.
100
+ This means you don't have to check before calling this function.
101
+
102
+ Args:
103
+ maybe_ref_schema: A `CoreSchema`, `ref`-based or not.
104
+
105
+ Raises:
106
+ LookupError: If the `ref` is not found.
107
+
108
+ Returns:
109
+ A concrete `CoreSchema`.
110
+ """
111
+ raise NotImplementedError
112
+
113
+ @property
114
+ def field_name(self) -> str | None:
115
+ """Get the name of the closest field to this validator."""
116
+ raise NotImplementedError
117
+
118
+ def _get_types_namespace(self) -> dict[str, Any] | None:
119
+ """Internal method used during type resolution for serializer annotations."""
120
+ raise NotImplementedError
venv/lib/python3.10/site-packages/pydantic/class_validators.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ """`class_validators` module is a backport module from V1."""
2
+ from ._migration import getattr_migration
3
+
4
+ __getattr__ = getattr_migration(__name__)
venv/lib/python3.10/site-packages/pydantic/color.py ADDED
@@ -0,0 +1,603 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Color definitions are used as per the CSS3
2
+ [CSS Color Module Level 3](http://www.w3.org/TR/css3-color/#svg-color) specification.
3
+
4
+ A few colors have multiple names referring to the sames colors, eg. `grey` and `gray` or `aqua` and `cyan`.
5
+
6
+ In these cases the _last_ color when sorted alphabetically takes preferences,
7
+ eg. `Color((0, 255, 255)).as_named() == 'cyan'` because "cyan" comes after "aqua".
8
+
9
+ Warning: Deprecated
10
+ The `Color` class is deprecated, use `pydantic_extra_types` instead.
11
+ See [`pydantic-extra-types.Color`](../usage/types/extra_types/color_types.md)
12
+ for more information.
13
+ """
14
+ import math
15
+ import re
16
+ from colorsys import hls_to_rgb, rgb_to_hls
17
+ from typing import Any, Callable, Optional, Tuple, Type, Union, cast
18
+
19
+ from pydantic_core import CoreSchema, PydanticCustomError, core_schema
20
+ from typing_extensions import deprecated
21
+
22
+ from ._internal import _repr
23
+ from ._internal._schema_generation_shared import GetJsonSchemaHandler as _GetJsonSchemaHandler
24
+ from .json_schema import JsonSchemaValue
25
+ from .warnings import PydanticDeprecatedSince20
26
+
27
+ ColorTuple = Union[Tuple[int, int, int], Tuple[int, int, int, float]]
28
+ ColorType = Union[ColorTuple, str]
29
+ HslColorTuple = Union[Tuple[float, float, float], Tuple[float, float, float, float]]
30
+
31
+
32
+ class RGBA:
33
+ """Internal use only as a representation of a color."""
34
+
35
+ __slots__ = 'r', 'g', 'b', 'alpha', '_tuple'
36
+
37
+ def __init__(self, r: float, g: float, b: float, alpha: Optional[float]):
38
+ self.r = r
39
+ self.g = g
40
+ self.b = b
41
+ self.alpha = alpha
42
+
43
+ self._tuple: Tuple[float, float, float, Optional[float]] = (r, g, b, alpha)
44
+
45
+ def __getitem__(self, item: Any) -> Any:
46
+ return self._tuple[item]
47
+
48
+
49
+ # these are not compiled here to avoid import slowdown, they'll be compiled the first time they're used, then cached
50
+ _r_255 = r'(\d{1,3}(?:\.\d+)?)'
51
+ _r_comma = r'\s*,\s*'
52
+ _r_alpha = r'(\d(?:\.\d+)?|\.\d+|\d{1,2}%)'
53
+ _r_h = r'(-?\d+(?:\.\d+)?|-?\.\d+)(deg|rad|turn)?'
54
+ _r_sl = r'(\d{1,3}(?:\.\d+)?)%'
55
+ r_hex_short = r'\s*(?:#|0x)?([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?\s*'
56
+ r_hex_long = r'\s*(?:#|0x)?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?\s*'
57
+ # CSS3 RGB examples: rgb(0, 0, 0), rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 50%)
58
+ r_rgb = rf'\s*rgba?\(\s*{_r_255}{_r_comma}{_r_255}{_r_comma}{_r_255}(?:{_r_comma}{_r_alpha})?\s*\)\s*'
59
+ # CSS3 HSL examples: hsl(270, 60%, 50%), hsla(270, 60%, 50%, 0.5), hsla(270, 60%, 50%, 50%)
60
+ r_hsl = rf'\s*hsla?\(\s*{_r_h}{_r_comma}{_r_sl}{_r_comma}{_r_sl}(?:{_r_comma}{_r_alpha})?\s*\)\s*'
61
+ # CSS4 RGB examples: rgb(0 0 0), rgb(0 0 0 / 0.5), rgb(0 0 0 / 50%), rgba(0 0 0 / 50%)
62
+ r_rgb_v4_style = rf'\s*rgba?\(\s*{_r_255}\s+{_r_255}\s+{_r_255}(?:\s*/\s*{_r_alpha})?\s*\)\s*'
63
+ # CSS4 HSL examples: hsl(270 60% 50%), hsl(270 60% 50% / 0.5), hsl(270 60% 50% / 50%), hsla(270 60% 50% / 50%)
64
+ r_hsl_v4_style = rf'\s*hsla?\(\s*{_r_h}\s+{_r_sl}\s+{_r_sl}(?:\s*/\s*{_r_alpha})?\s*\)\s*'
65
+
66
+ # colors where the two hex characters are the same, if all colors match this the short version of hex colors can be used
67
+ repeat_colors = {int(c * 2, 16) for c in '0123456789abcdef'}
68
+ rads = 2 * math.pi
69
+
70
+
71
+ @deprecated(
72
+ 'The `Color` class is deprecated, use `pydantic_extra_types` instead. '
73
+ 'See https://docs.pydantic.dev/latest/api/pydantic_extra_types_color/.',
74
+ category=PydanticDeprecatedSince20,
75
+ )
76
+ class Color(_repr.Representation):
77
+ """Represents a color."""
78
+
79
+ __slots__ = '_original', '_rgba'
80
+
81
+ def __init__(self, value: ColorType) -> None:
82
+ self._rgba: RGBA
83
+ self._original: ColorType
84
+ if isinstance(value, (tuple, list)):
85
+ self._rgba = parse_tuple(value)
86
+ elif isinstance(value, str):
87
+ self._rgba = parse_str(value)
88
+ elif isinstance(value, Color):
89
+ self._rgba = value._rgba
90
+ value = value._original
91
+ else:
92
+ raise PydanticCustomError(
93
+ 'color_error', 'value is not a valid color: value must be a tuple, list or string'
94
+ )
95
+
96
+ # if we've got here value must be a valid color
97
+ self._original = value
98
+
99
+ @classmethod
100
+ def __get_pydantic_json_schema__(
101
+ cls, core_schema: core_schema.CoreSchema, handler: _GetJsonSchemaHandler
102
+ ) -> JsonSchemaValue:
103
+ field_schema = {}
104
+ field_schema.update(type='string', format='color')
105
+ return field_schema
106
+
107
+ def original(self) -> ColorType:
108
+ """Original value passed to `Color`."""
109
+ return self._original
110
+
111
+ def as_named(self, *, fallback: bool = False) -> str:
112
+ """Returns the name of the color if it can be found in `COLORS_BY_VALUE` dictionary,
113
+ otherwise returns the hexadecimal representation of the color or raises `ValueError`.
114
+
115
+ Args:
116
+ fallback: If True, falls back to returning the hexadecimal representation of
117
+ the color instead of raising a ValueError when no named color is found.
118
+
119
+ Returns:
120
+ The name of the color, or the hexadecimal representation of the color.
121
+
122
+ Raises:
123
+ ValueError: When no named color is found and fallback is `False`.
124
+ """
125
+ if self._rgba.alpha is None:
126
+ rgb = cast(Tuple[int, int, int], self.as_rgb_tuple())
127
+ try:
128
+ return COLORS_BY_VALUE[rgb]
129
+ except KeyError as e:
130
+ if fallback:
131
+ return self.as_hex()
132
+ else:
133
+ raise ValueError('no named color found, use fallback=True, as_hex() or as_rgb()') from e
134
+ else:
135
+ return self.as_hex()
136
+
137
+ def as_hex(self) -> str:
138
+ """Returns the hexadecimal representation of the color.
139
+
140
+ Hex string representing the color can be 3, 4, 6, or 8 characters depending on whether the string
141
+ a "short" representation of the color is possible and whether there's an alpha channel.
142
+
143
+ Returns:
144
+ The hexadecimal representation of the color.
145
+ """
146
+ values = [float_to_255(c) for c in self._rgba[:3]]
147
+ if self._rgba.alpha is not None:
148
+ values.append(float_to_255(self._rgba.alpha))
149
+
150
+ as_hex = ''.join(f'{v:02x}' for v in values)
151
+ if all(c in repeat_colors for c in values):
152
+ as_hex = ''.join(as_hex[c] for c in range(0, len(as_hex), 2))
153
+ return '#' + as_hex
154
+
155
+ def as_rgb(self) -> str:
156
+ """Color as an `rgb(<r>, <g>, <b>)` or `rgba(<r>, <g>, <b>, <a>)` string."""
157
+ if self._rgba.alpha is None:
158
+ return f'rgb({float_to_255(self._rgba.r)}, {float_to_255(self._rgba.g)}, {float_to_255(self._rgba.b)})'
159
+ else:
160
+ return (
161
+ f'rgba({float_to_255(self._rgba.r)}, {float_to_255(self._rgba.g)}, {float_to_255(self._rgba.b)}, '
162
+ f'{round(self._alpha_float(), 2)})'
163
+ )
164
+
165
+ def as_rgb_tuple(self, *, alpha: Optional[bool] = None) -> ColorTuple:
166
+ """Returns the color as an RGB or RGBA tuple.
167
+
168
+ Args:
169
+ alpha: Whether to include the alpha channel. There are three options for this input:
170
+
171
+ - `None` (default): Include alpha only if it's set. (e.g. not `None`)
172
+ - `True`: Always include alpha.
173
+ - `False`: Always omit alpha.
174
+
175
+ Returns:
176
+ A tuple that contains the values of the red, green, and blue channels in the range 0 to 255.
177
+ If alpha is included, it is in the range 0 to 1.
178
+ """
179
+ r, g, b = (float_to_255(c) for c in self._rgba[:3])
180
+ if alpha is None:
181
+ if self._rgba.alpha is None:
182
+ return r, g, b
183
+ else:
184
+ return r, g, b, self._alpha_float()
185
+ elif alpha:
186
+ return r, g, b, self._alpha_float()
187
+ else:
188
+ # alpha is False
189
+ return r, g, b
190
+
191
+ def as_hsl(self) -> str:
192
+ """Color as an `hsl(<h>, <s>, <l>)` or `hsl(<h>, <s>, <l>, <a>)` string."""
193
+ if self._rgba.alpha is None:
194
+ h, s, li = self.as_hsl_tuple(alpha=False) # type: ignore
195
+ return f'hsl({h * 360:0.0f}, {s:0.0%}, {li:0.0%})'
196
+ else:
197
+ h, s, li, a = self.as_hsl_tuple(alpha=True) # type: ignore
198
+ return f'hsl({h * 360:0.0f}, {s:0.0%}, {li:0.0%}, {round(a, 2)})'
199
+
200
+ def as_hsl_tuple(self, *, alpha: Optional[bool] = None) -> HslColorTuple:
201
+ """Returns the color as an HSL or HSLA tuple.
202
+
203
+ Args:
204
+ alpha: Whether to include the alpha channel.
205
+
206
+ - `None` (default): Include the alpha channel only if it's set (e.g. not `None`).
207
+ - `True`: Always include alpha.
208
+ - `False`: Always omit alpha.
209
+
210
+ Returns:
211
+ The color as a tuple of hue, saturation, lightness, and alpha (if included).
212
+ All elements are in the range 0 to 1.
213
+
214
+ Note:
215
+ This is HSL as used in HTML and most other places, not HLS as used in Python's `colorsys`.
216
+ """
217
+ h, l, s = rgb_to_hls(self._rgba.r, self._rgba.g, self._rgba.b) # noqa: E741
218
+ if alpha is None:
219
+ if self._rgba.alpha is None:
220
+ return h, s, l
221
+ else:
222
+ return h, s, l, self._alpha_float()
223
+ if alpha:
224
+ return h, s, l, self._alpha_float()
225
+ else:
226
+ # alpha is False
227
+ return h, s, l
228
+
229
+ def _alpha_float(self) -> float:
230
+ return 1 if self._rgba.alpha is None else self._rgba.alpha
231
+
232
+ @classmethod
233
+ def __get_pydantic_core_schema__(
234
+ cls, source: Type[Any], handler: Callable[[Any], CoreSchema]
235
+ ) -> core_schema.CoreSchema:
236
+ return core_schema.with_info_plain_validator_function(
237
+ cls._validate, serialization=core_schema.to_string_ser_schema()
238
+ )
239
+
240
+ @classmethod
241
+ def _validate(cls, __input_value: Any, _: Any) -> 'Color':
242
+ return cls(__input_value)
243
+
244
+ def __str__(self) -> str:
245
+ return self.as_named(fallback=True)
246
+
247
+ def __repr_args__(self) -> '_repr.ReprArgs':
248
+ return [(None, self.as_named(fallback=True))] + [('rgb', self.as_rgb_tuple())]
249
+
250
+ def __eq__(self, other: Any) -> bool:
251
+ return isinstance(other, Color) and self.as_rgb_tuple() == other.as_rgb_tuple()
252
+
253
+ def __hash__(self) -> int:
254
+ return hash(self.as_rgb_tuple())
255
+
256
+
257
+ def parse_tuple(value: Tuple[Any, ...]) -> RGBA:
258
+ """Parse a tuple or list to get RGBA values.
259
+
260
+ Args:
261
+ value: A tuple or list.
262
+
263
+ Returns:
264
+ An `RGBA` tuple parsed from the input tuple.
265
+
266
+ Raises:
267
+ PydanticCustomError: If tuple is not valid.
268
+ """
269
+ if len(value) == 3:
270
+ r, g, b = (parse_color_value(v) for v in value)
271
+ return RGBA(r, g, b, None)
272
+ elif len(value) == 4:
273
+ r, g, b = (parse_color_value(v) for v in value[:3])
274
+ return RGBA(r, g, b, parse_float_alpha(value[3]))
275
+ else:
276
+ raise PydanticCustomError('color_error', 'value is not a valid color: tuples must have length 3 or 4')
277
+
278
+
279
+ def parse_str(value: str) -> RGBA:
280
+ """Parse a string representing a color to an RGBA tuple.
281
+
282
+ Possible formats for the input string include:
283
+
284
+ * named color, see `COLORS_BY_NAME`
285
+ * hex short eg. `<prefix>fff` (prefix can be `#`, `0x` or nothing)
286
+ * hex long eg. `<prefix>ffffff` (prefix can be `#`, `0x` or nothing)
287
+ * `rgb(<r>, <g>, <b>)`
288
+ * `rgba(<r>, <g>, <b>, <a>)`
289
+
290
+ Args:
291
+ value: A string representing a color.
292
+
293
+ Returns:
294
+ An `RGBA` tuple parsed from the input string.
295
+
296
+ Raises:
297
+ ValueError: If the input string cannot be parsed to an RGBA tuple.
298
+ """
299
+ value_lower = value.lower()
300
+ try:
301
+ r, g, b = COLORS_BY_NAME[value_lower]
302
+ except KeyError:
303
+ pass
304
+ else:
305
+ return ints_to_rgba(r, g, b, None)
306
+
307
+ m = re.fullmatch(r_hex_short, value_lower)
308
+ if m:
309
+ *rgb, a = m.groups()
310
+ r, g, b = (int(v * 2, 16) for v in rgb)
311
+ if a:
312
+ alpha: Optional[float] = int(a * 2, 16) / 255
313
+ else:
314
+ alpha = None
315
+ return ints_to_rgba(r, g, b, alpha)
316
+
317
+ m = re.fullmatch(r_hex_long, value_lower)
318
+ if m:
319
+ *rgb, a = m.groups()
320
+ r, g, b = (int(v, 16) for v in rgb)
321
+ if a:
322
+ alpha = int(a, 16) / 255
323
+ else:
324
+ alpha = None
325
+ return ints_to_rgba(r, g, b, alpha)
326
+
327
+ m = re.fullmatch(r_rgb, value_lower) or re.fullmatch(r_rgb_v4_style, value_lower)
328
+ if m:
329
+ return ints_to_rgba(*m.groups()) # type: ignore
330
+
331
+ m = re.fullmatch(r_hsl, value_lower) or re.fullmatch(r_hsl_v4_style, value_lower)
332
+ if m:
333
+ return parse_hsl(*m.groups()) # type: ignore
334
+
335
+ raise PydanticCustomError('color_error', 'value is not a valid color: string not recognised as a valid color')
336
+
337
+
338
+ def ints_to_rgba(r: Union[int, str], g: Union[int, str], b: Union[int, str], alpha: Optional[float] = None) -> RGBA:
339
+ """Converts integer or string values for RGB color and an optional alpha value to an `RGBA` object.
340
+
341
+ Args:
342
+ r: An integer or string representing the red color value.
343
+ g: An integer or string representing the green color value.
344
+ b: An integer or string representing the blue color value.
345
+ alpha: A float representing the alpha value. Defaults to None.
346
+
347
+ Returns:
348
+ An instance of the `RGBA` class with the corresponding color and alpha values.
349
+ """
350
+ return RGBA(parse_color_value(r), parse_color_value(g), parse_color_value(b), parse_float_alpha(alpha))
351
+
352
+
353
+ def parse_color_value(value: Union[int, str], max_val: int = 255) -> float:
354
+ """Parse the color value provided and return a number between 0 and 1.
355
+
356
+ Args:
357
+ value: An integer or string color value.
358
+ max_val: Maximum range value. Defaults to 255.
359
+
360
+ Raises:
361
+ PydanticCustomError: If the value is not a valid color.
362
+
363
+ Returns:
364
+ A number between 0 and 1.
365
+ """
366
+ try:
367
+ color = float(value)
368
+ except ValueError:
369
+ raise PydanticCustomError('color_error', 'value is not a valid color: color values must be a valid number')
370
+ if 0 <= color <= max_val:
371
+ return color / max_val
372
+ else:
373
+ raise PydanticCustomError(
374
+ 'color_error',
375
+ 'value is not a valid color: color values must be in the range 0 to {max_val}',
376
+ {'max_val': max_val},
377
+ )
378
+
379
+
380
+ def parse_float_alpha(value: Union[None, str, float, int]) -> Optional[float]:
381
+ """Parse an alpha value checking it's a valid float in the range 0 to 1.
382
+
383
+ Args:
384
+ value: The input value to parse.
385
+
386
+ Returns:
387
+ The parsed value as a float, or `None` if the value was None or equal 1.
388
+
389
+ Raises:
390
+ PydanticCustomError: If the input value cannot be successfully parsed as a float in the expected range.
391
+ """
392
+ if value is None:
393
+ return None
394
+ try:
395
+ if isinstance(value, str) and value.endswith('%'):
396
+ alpha = float(value[:-1]) / 100
397
+ else:
398
+ alpha = float(value)
399
+ except ValueError:
400
+ raise PydanticCustomError('color_error', 'value is not a valid color: alpha values must be a valid float')
401
+
402
+ if math.isclose(alpha, 1):
403
+ return None
404
+ elif 0 <= alpha <= 1:
405
+ return alpha
406
+ else:
407
+ raise PydanticCustomError('color_error', 'value is not a valid color: alpha values must be in the range 0 to 1')
408
+
409
+
410
+ def parse_hsl(h: str, h_units: str, sat: str, light: str, alpha: Optional[float] = None) -> RGBA:
411
+ """Parse raw hue, saturation, lightness, and alpha values and convert to RGBA.
412
+
413
+ Args:
414
+ h: The hue value.
415
+ h_units: The unit for hue value.
416
+ sat: The saturation value.
417
+ light: The lightness value.
418
+ alpha: Alpha value.
419
+
420
+ Returns:
421
+ An instance of `RGBA`.
422
+ """
423
+ s_value, l_value = parse_color_value(sat, 100), parse_color_value(light, 100)
424
+
425
+ h_value = float(h)
426
+ if h_units in {None, 'deg'}:
427
+ h_value = h_value % 360 / 360
428
+ elif h_units == 'rad':
429
+ h_value = h_value % rads / rads
430
+ else:
431
+ # turns
432
+ h_value = h_value % 1
433
+
434
+ r, g, b = hls_to_rgb(h_value, l_value, s_value)
435
+ return RGBA(r, g, b, parse_float_alpha(alpha))
436
+
437
+
438
+ def float_to_255(c: float) -> int:
439
+ """Converts a float value between 0 and 1 (inclusive) to an integer between 0 and 255 (inclusive).
440
+
441
+ Args:
442
+ c: The float value to be converted. Must be between 0 and 1 (inclusive).
443
+
444
+ Returns:
445
+ The integer equivalent of the given float value rounded to the nearest whole number.
446
+
447
+ Raises:
448
+ ValueError: If the given float value is outside the acceptable range of 0 to 1 (inclusive).
449
+ """
450
+ return int(round(c * 255))
451
+
452
+
453
+ COLORS_BY_NAME = {
454
+ 'aliceblue': (240, 248, 255),
455
+ 'antiquewhite': (250, 235, 215),
456
+ 'aqua': (0, 255, 255),
457
+ 'aquamarine': (127, 255, 212),
458
+ 'azure': (240, 255, 255),
459
+ 'beige': (245, 245, 220),
460
+ 'bisque': (255, 228, 196),
461
+ 'black': (0, 0, 0),
462
+ 'blanchedalmond': (255, 235, 205),
463
+ 'blue': (0, 0, 255),
464
+ 'blueviolet': (138, 43, 226),
465
+ 'brown': (165, 42, 42),
466
+ 'burlywood': (222, 184, 135),
467
+ 'cadetblue': (95, 158, 160),
468
+ 'chartreuse': (127, 255, 0),
469
+ 'chocolate': (210, 105, 30),
470
+ 'coral': (255, 127, 80),
471
+ 'cornflowerblue': (100, 149, 237),
472
+ 'cornsilk': (255, 248, 220),
473
+ 'crimson': (220, 20, 60),
474
+ 'cyan': (0, 255, 255),
475
+ 'darkblue': (0, 0, 139),
476
+ 'darkcyan': (0, 139, 139),
477
+ 'darkgoldenrod': (184, 134, 11),
478
+ 'darkgray': (169, 169, 169),
479
+ 'darkgreen': (0, 100, 0),
480
+ 'darkgrey': (169, 169, 169),
481
+ 'darkkhaki': (189, 183, 107),
482
+ 'darkmagenta': (139, 0, 139),
483
+ 'darkolivegreen': (85, 107, 47),
484
+ 'darkorange': (255, 140, 0),
485
+ 'darkorchid': (153, 50, 204),
486
+ 'darkred': (139, 0, 0),
487
+ 'darksalmon': (233, 150, 122),
488
+ 'darkseagreen': (143, 188, 143),
489
+ 'darkslateblue': (72, 61, 139),
490
+ 'darkslategray': (47, 79, 79),
491
+ 'darkslategrey': (47, 79, 79),
492
+ 'darkturquoise': (0, 206, 209),
493
+ 'darkviolet': (148, 0, 211),
494
+ 'deeppink': (255, 20, 147),
495
+ 'deepskyblue': (0, 191, 255),
496
+ 'dimgray': (105, 105, 105),
497
+ 'dimgrey': (105, 105, 105),
498
+ 'dodgerblue': (30, 144, 255),
499
+ 'firebrick': (178, 34, 34),
500
+ 'floralwhite': (255, 250, 240),
501
+ 'forestgreen': (34, 139, 34),
502
+ 'fuchsia': (255, 0, 255),
503
+ 'gainsboro': (220, 220, 220),
504
+ 'ghostwhite': (248, 248, 255),
505
+ 'gold': (255, 215, 0),
506
+ 'goldenrod': (218, 165, 32),
507
+ 'gray': (128, 128, 128),
508
+ 'green': (0, 128, 0),
509
+ 'greenyellow': (173, 255, 47),
510
+ 'grey': (128, 128, 128),
511
+ 'honeydew': (240, 255, 240),
512
+ 'hotpink': (255, 105, 180),
513
+ 'indianred': (205, 92, 92),
514
+ 'indigo': (75, 0, 130),
515
+ 'ivory': (255, 255, 240),
516
+ 'khaki': (240, 230, 140),
517
+ 'lavender': (230, 230, 250),
518
+ 'lavenderblush': (255, 240, 245),
519
+ 'lawngreen': (124, 252, 0),
520
+ 'lemonchiffon': (255, 250, 205),
521
+ 'lightblue': (173, 216, 230),
522
+ 'lightcoral': (240, 128, 128),
523
+ 'lightcyan': (224, 255, 255),
524
+ 'lightgoldenrodyellow': (250, 250, 210),
525
+ 'lightgray': (211, 211, 211),
526
+ 'lightgreen': (144, 238, 144),
527
+ 'lightgrey': (211, 211, 211),
528
+ 'lightpink': (255, 182, 193),
529
+ 'lightsalmon': (255, 160, 122),
530
+ 'lightseagreen': (32, 178, 170),
531
+ 'lightskyblue': (135, 206, 250),
532
+ 'lightslategray': (119, 136, 153),
533
+ 'lightslategrey': (119, 136, 153),
534
+ 'lightsteelblue': (176, 196, 222),
535
+ 'lightyellow': (255, 255, 224),
536
+ 'lime': (0, 255, 0),
537
+ 'limegreen': (50, 205, 50),
538
+ 'linen': (250, 240, 230),
539
+ 'magenta': (255, 0, 255),
540
+ 'maroon': (128, 0, 0),
541
+ 'mediumaquamarine': (102, 205, 170),
542
+ 'mediumblue': (0, 0, 205),
543
+ 'mediumorchid': (186, 85, 211),
544
+ 'mediumpurple': (147, 112, 219),
545
+ 'mediumseagreen': (60, 179, 113),
546
+ 'mediumslateblue': (123, 104, 238),
547
+ 'mediumspringgreen': (0, 250, 154),
548
+ 'mediumturquoise': (72, 209, 204),
549
+ 'mediumvioletred': (199, 21, 133),
550
+ 'midnightblue': (25, 25, 112),
551
+ 'mintcream': (245, 255, 250),
552
+ 'mistyrose': (255, 228, 225),
553
+ 'moccasin': (255, 228, 181),
554
+ 'navajowhite': (255, 222, 173),
555
+ 'navy': (0, 0, 128),
556
+ 'oldlace': (253, 245, 230),
557
+ 'olive': (128, 128, 0),
558
+ 'olivedrab': (107, 142, 35),
559
+ 'orange': (255, 165, 0),
560
+ 'orangered': (255, 69, 0),
561
+ 'orchid': (218, 112, 214),
562
+ 'palegoldenrod': (238, 232, 170),
563
+ 'palegreen': (152, 251, 152),
564
+ 'paleturquoise': (175, 238, 238),
565
+ 'palevioletred': (219, 112, 147),
566
+ 'papayawhip': (255, 239, 213),
567
+ 'peachpuff': (255, 218, 185),
568
+ 'peru': (205, 133, 63),
569
+ 'pink': (255, 192, 203),
570
+ 'plum': (221, 160, 221),
571
+ 'powderblue': (176, 224, 230),
572
+ 'purple': (128, 0, 128),
573
+ 'red': (255, 0, 0),
574
+ 'rosybrown': (188, 143, 143),
575
+ 'royalblue': (65, 105, 225),
576
+ 'saddlebrown': (139, 69, 19),
577
+ 'salmon': (250, 128, 114),
578
+ 'sandybrown': (244, 164, 96),
579
+ 'seagreen': (46, 139, 87),
580
+ 'seashell': (255, 245, 238),
581
+ 'sienna': (160, 82, 45),
582
+ 'silver': (192, 192, 192),
583
+ 'skyblue': (135, 206, 235),
584
+ 'slateblue': (106, 90, 205),
585
+ 'slategray': (112, 128, 144),
586
+ 'slategrey': (112, 128, 144),
587
+ 'snow': (255, 250, 250),
588
+ 'springgreen': (0, 255, 127),
589
+ 'steelblue': (70, 130, 180),
590
+ 'tan': (210, 180, 140),
591
+ 'teal': (0, 128, 128),
592
+ 'thistle': (216, 191, 216),
593
+ 'tomato': (255, 99, 71),
594
+ 'turquoise': (64, 224, 208),
595
+ 'violet': (238, 130, 238),
596
+ 'wheat': (245, 222, 179),
597
+ 'white': (255, 255, 255),
598
+ 'whitesmoke': (245, 245, 245),
599
+ 'yellow': (255, 255, 0),
600
+ 'yellowgreen': (154, 205, 50),
601
+ }
602
+
603
+ COLORS_BY_VALUE = {v: k for k, v in COLORS_BY_NAME.items()}
venv/lib/python3.10/site-packages/pydantic/config.py ADDED
@@ -0,0 +1,1003 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Configuration for Pydantic models."""
2
+ from __future__ import annotations as _annotations
3
+
4
+ from typing import TYPE_CHECKING, Any, Callable, Dict, List, Type, TypeVar, Union
5
+
6
+ from typing_extensions import Literal, TypeAlias, TypedDict
7
+
8
+ from ._migration import getattr_migration
9
+ from .aliases import AliasGenerator
10
+
11
+ if TYPE_CHECKING:
12
+ from ._internal._generate_schema import GenerateSchema as _GenerateSchema
13
+
14
+ __all__ = ('ConfigDict', 'with_config')
15
+
16
+
17
+ JsonValue: TypeAlias = Union[int, float, str, bool, None, List['JsonValue'], 'JsonDict']
18
+ JsonDict: TypeAlias = Dict[str, JsonValue]
19
+
20
+ JsonEncoder = Callable[[Any], Any]
21
+
22
+ JsonSchemaExtraCallable: TypeAlias = Union[
23
+ Callable[[JsonDict], None],
24
+ Callable[[JsonDict, Type[Any]], None],
25
+ ]
26
+
27
+ ExtraValues = Literal['allow', 'ignore', 'forbid']
28
+
29
+
30
+ class ConfigDict(TypedDict, total=False):
31
+ """A TypedDict for configuring Pydantic behaviour."""
32
+
33
+ title: str | None
34
+ """The title for the generated JSON schema, defaults to the model's name"""
35
+
36
+ str_to_lower: bool
37
+ """Whether to convert all characters to lowercase for str types. Defaults to `False`."""
38
+
39
+ str_to_upper: bool
40
+ """Whether to convert all characters to uppercase for str types. Defaults to `False`."""
41
+ str_strip_whitespace: bool
42
+ """Whether to strip leading and trailing whitespace for str types."""
43
+
44
+ str_min_length: int
45
+ """The minimum length for str types. Defaults to `None`."""
46
+
47
+ str_max_length: int | None
48
+ """The maximum length for str types. Defaults to `None`."""
49
+
50
+ extra: ExtraValues | None
51
+ """
52
+ Whether to ignore, allow, or forbid extra attributes during model initialization. Defaults to `'ignore'`.
53
+
54
+ You can configure how pydantic handles the attributes that are not defined in the model:
55
+
56
+ * `allow` - Allow any extra attributes.
57
+ * `forbid` - Forbid any extra attributes.
58
+ * `ignore` - Ignore any extra attributes.
59
+
60
+ ```py
61
+ from pydantic import BaseModel, ConfigDict
62
+
63
+
64
+ class User(BaseModel):
65
+ model_config = ConfigDict(extra='ignore') # (1)!
66
+
67
+ name: str
68
+
69
+
70
+ user = User(name='John Doe', age=20) # (2)!
71
+ print(user)
72
+ #> name='John Doe'
73
+ ```
74
+
75
+ 1. This is the default behaviour.
76
+ 2. The `age` argument is ignored.
77
+
78
+ Instead, with `extra='allow'`, the `age` argument is included:
79
+
80
+ ```py
81
+ from pydantic import BaseModel, ConfigDict
82
+
83
+
84
+ class User(BaseModel):
85
+ model_config = ConfigDict(extra='allow')
86
+
87
+ name: str
88
+
89
+
90
+ user = User(name='John Doe', age=20) # (1)!
91
+ print(user)
92
+ #> name='John Doe' age=20
93
+ ```
94
+
95
+ 1. The `age` argument is included.
96
+
97
+ With `extra='forbid'`, an error is raised:
98
+
99
+ ```py
100
+ from pydantic import BaseModel, ConfigDict, ValidationError
101
+
102
+
103
+ class User(BaseModel):
104
+ model_config = ConfigDict(extra='forbid')
105
+
106
+ name: str
107
+
108
+
109
+ try:
110
+ User(name='John Doe', age=20)
111
+ except ValidationError as e:
112
+ print(e)
113
+ '''
114
+ 1 validation error for User
115
+ age
116
+ Extra inputs are not permitted [type=extra_forbidden, input_value=20, input_type=int]
117
+ '''
118
+ ```
119
+ """
120
+
121
+ frozen: bool
122
+ """
123
+ Whether models are faux-immutable, i.e. whether `__setattr__` is allowed, and also generates
124
+ a `__hash__()` method for the model. This makes instances of the model potentially hashable if all the
125
+ attributes are hashable. Defaults to `False`.
126
+
127
+ Note:
128
+ On V1, the inverse of this setting was called `allow_mutation`, and was `True` by default.
129
+ """
130
+
131
+ populate_by_name: bool
132
+ """
133
+ Whether an aliased field may be populated by its name as given by the model
134
+ attribute, as well as the alias. Defaults to `False`.
135
+
136
+ Note:
137
+ The name of this configuration setting was changed in **v2.0** from
138
+ `allow_population_by_field_name` to `populate_by_name`.
139
+
140
+ ```py
141
+ from pydantic import BaseModel, ConfigDict, Field
142
+
143
+
144
+ class User(BaseModel):
145
+ model_config = ConfigDict(populate_by_name=True)
146
+
147
+ name: str = Field(alias='full_name') # (1)!
148
+ age: int
149
+
150
+
151
+ user = User(full_name='John Doe', age=20) # (2)!
152
+ print(user)
153
+ #> name='John Doe' age=20
154
+ user = User(name='John Doe', age=20) # (3)!
155
+ print(user)
156
+ #> name='John Doe' age=20
157
+ ```
158
+
159
+ 1. The field `'name'` has an alias `'full_name'`.
160
+ 2. The model is populated by the alias `'full_name'`.
161
+ 3. The model is populated by the field name `'name'`.
162
+ """
163
+
164
+ use_enum_values: bool
165
+ """
166
+ Whether to populate models with the `value` property of enums, rather than the raw enum.
167
+ This may be useful if you want to serialize `model.model_dump()` later. Defaults to `False`.
168
+
169
+ !!! note
170
+ If you have an `Optional[Enum]` value that you set a default for, you need to use `validate_default=True`
171
+ for said Field to ensure that the `use_enum_values` flag takes effect on the default, as extracting an
172
+ enum's value occurs during validation, not serialization.
173
+
174
+ ```py
175
+ from enum import Enum
176
+ from typing import Optional
177
+
178
+ from pydantic import BaseModel, ConfigDict, Field
179
+
180
+
181
+ class SomeEnum(Enum):
182
+ FOO = 'foo'
183
+ BAR = 'bar'
184
+ BAZ = 'baz'
185
+
186
+
187
+ class SomeModel(BaseModel):
188
+ model_config = ConfigDict(use_enum_values=True)
189
+
190
+ some_enum: SomeEnum
191
+ another_enum: Optional[SomeEnum] = Field(default=SomeEnum.FOO, validate_default=True)
192
+
193
+
194
+ model1 = SomeModel(some_enum=SomeEnum.BAR)
195
+ print(model1.model_dump())
196
+ # {'some_enum': 'bar', 'another_enum': 'foo'}
197
+
198
+ model2 = SomeModel(some_enum=SomeEnum.BAR, another_enum=SomeEnum.BAZ)
199
+ print(model2.model_dump())
200
+ #> {'some_enum': 'bar', 'another_enum': 'baz'}
201
+ ```
202
+ """
203
+
204
+ validate_assignment: bool
205
+ """
206
+ Whether to validate the data when the model is changed. Defaults to `False`.
207
+
208
+ The default behavior of Pydantic is to validate the data when the model is created.
209
+
210
+ In case the user changes the data after the model is created, the model is _not_ revalidated.
211
+
212
+ ```py
213
+ from pydantic import BaseModel
214
+
215
+ class User(BaseModel):
216
+ name: str
217
+
218
+ user = User(name='John Doe') # (1)!
219
+ print(user)
220
+ #> name='John Doe'
221
+ user.name = 123 # (1)!
222
+ print(user)
223
+ #> name=123
224
+ ```
225
+
226
+ 1. The validation happens only when the model is created.
227
+ 2. The validation does not happen when the data is changed.
228
+
229
+ In case you want to revalidate the model when the data is changed, you can use `validate_assignment=True`:
230
+
231
+ ```py
232
+ from pydantic import BaseModel, ValidationError
233
+
234
+ class User(BaseModel, validate_assignment=True): # (1)!
235
+ name: str
236
+
237
+ user = User(name='John Doe') # (2)!
238
+ print(user)
239
+ #> name='John Doe'
240
+ try:
241
+ user.name = 123 # (3)!
242
+ except ValidationError as e:
243
+ print(e)
244
+ '''
245
+ 1 validation error for User
246
+ name
247
+ Input should be a valid string [type=string_type, input_value=123, input_type=int]
248
+ '''
249
+ ```
250
+
251
+ 1. You can either use class keyword arguments, or `model_config` to set `validate_assignment=True`.
252
+ 2. The validation happens when the model is created.
253
+ 3. The validation _also_ happens when the data is changed.
254
+ """
255
+
256
+ arbitrary_types_allowed: bool
257
+ """
258
+ Whether arbitrary types are allowed for field types. Defaults to `False`.
259
+
260
+ ```py
261
+ from pydantic import BaseModel, ConfigDict, ValidationError
262
+
263
+ # This is not a pydantic model, it's an arbitrary class
264
+ class Pet:
265
+ def __init__(self, name: str):
266
+ self.name = name
267
+
268
+ class Model(BaseModel):
269
+ model_config = ConfigDict(arbitrary_types_allowed=True)
270
+
271
+ pet: Pet
272
+ owner: str
273
+
274
+ pet = Pet(name='Hedwig')
275
+ # A simple check of instance type is used to validate the data
276
+ model = Model(owner='Harry', pet=pet)
277
+ print(model)
278
+ #> pet=<__main__.Pet object at 0x0123456789ab> owner='Harry'
279
+ print(model.pet)
280
+ #> <__main__.Pet object at 0x0123456789ab>
281
+ print(model.pet.name)
282
+ #> Hedwig
283
+ print(type(model.pet))
284
+ #> <class '__main__.Pet'>
285
+ try:
286
+ # If the value is not an instance of the type, it's invalid
287
+ Model(owner='Harry', pet='Hedwig')
288
+ except ValidationError as e:
289
+ print(e)
290
+ '''
291
+ 1 validation error for Model
292
+ pet
293
+ Input should be an instance of Pet [type=is_instance_of, input_value='Hedwig', input_type=str]
294
+ '''
295
+
296
+ # Nothing in the instance of the arbitrary type is checked
297
+ # Here name probably should have been a str, but it's not validated
298
+ pet2 = Pet(name=42)
299
+ model2 = Model(owner='Harry', pet=pet2)
300
+ print(model2)
301
+ #> pet=<__main__.Pet object at 0x0123456789ab> owner='Harry'
302
+ print(model2.pet)
303
+ #> <__main__.Pet object at 0x0123456789ab>
304
+ print(model2.pet.name)
305
+ #> 42
306
+ print(type(model2.pet))
307
+ #> <class '__main__.Pet'>
308
+ ```
309
+ """
310
+
311
+ from_attributes: bool
312
+ """
313
+ Whether to build models and look up discriminators of tagged unions using python object attributes.
314
+ """
315
+
316
+ loc_by_alias: bool
317
+ """Whether to use the actual key provided in the data (e.g. alias) for error `loc`s rather than the field's name. Defaults to `True`."""
318
+
319
+ alias_generator: Callable[[str], str] | AliasGenerator | None
320
+ """
321
+ A callable that takes a field name and returns an alias for it
322
+ or an instance of [`AliasGenerator`][pydantic.aliases.AliasGenerator]. Defaults to `None`.
323
+
324
+ When using a callable, the alias generator is used for both validation and serialization.
325
+ If you want to use different alias generators for validation and serialization, you can use
326
+ [`AliasGenerator`][pydantic.aliases.AliasGenerator] instead.
327
+
328
+ If data source field names do not match your code style (e. g. CamelCase fields),
329
+ you can automatically generate aliases using `alias_generator`. Here's an example with
330
+ a basic callable:
331
+
332
+ ```py
333
+ from pydantic import BaseModel, ConfigDict
334
+ from pydantic.alias_generators import to_pascal
335
+
336
+ class Voice(BaseModel):
337
+ model_config = ConfigDict(alias_generator=to_pascal)
338
+
339
+ name: str
340
+ language_code: str
341
+
342
+ voice = Voice(Name='Filiz', LanguageCode='tr-TR')
343
+ print(voice.language_code)
344
+ #> tr-TR
345
+ print(voice.model_dump(by_alias=True))
346
+ #> {'Name': 'Filiz', 'LanguageCode': 'tr-TR'}
347
+ ```
348
+
349
+ If you want to use different alias generators for validation and serialization, you can use
350
+ [`AliasGenerator`][pydantic.aliases.AliasGenerator].
351
+
352
+ ```py
353
+ from pydantic import AliasGenerator, BaseModel, ConfigDict
354
+ from pydantic.alias_generators import to_camel, to_pascal
355
+
356
+ class Athlete(BaseModel):
357
+ first_name: str
358
+ last_name: str
359
+ sport: str
360
+
361
+ model_config = ConfigDict(
362
+ alias_generator=AliasGenerator(
363
+ validation_alias=to_camel,
364
+ serialization_alias=to_pascal,
365
+ )
366
+ )
367
+
368
+ athlete = Athlete(firstName='John', lastName='Doe', sport='track')
369
+ print(athlete.model_dump(by_alias=True))
370
+ #> {'FirstName': 'John', 'LastName': 'Doe', 'Sport': 'track'}
371
+ ```
372
+
373
+ Note:
374
+ Pydantic offers three built-in alias generators: [`to_pascal`][pydantic.alias_generators.to_pascal],
375
+ [`to_camel`][pydantic.alias_generators.to_camel], and [`to_snake`][pydantic.alias_generators.to_snake].
376
+ """
377
+
378
+ ignored_types: tuple[type, ...]
379
+ """A tuple of types that may occur as values of class attributes without annotations. This is
380
+ typically used for custom descriptors (classes that behave like `property`). If an attribute is set on a
381
+ class without an annotation and has a type that is not in this tuple (or otherwise recognized by
382
+ _pydantic_), an error will be raised. Defaults to `()`.
383
+ """
384
+
385
+ allow_inf_nan: bool
386
+ """Whether to allow infinity (`+inf` an `-inf`) and NaN values to float fields. Defaults to `True`."""
387
+
388
+ json_schema_extra: JsonDict | JsonSchemaExtraCallable | None
389
+ """A dict or callable to provide extra JSON schema properties. Defaults to `None`."""
390
+
391
+ json_encoders: dict[type[object], JsonEncoder] | None
392
+ """
393
+ A `dict` of custom JSON encoders for specific types. Defaults to `None`.
394
+
395
+ !!! warning "Deprecated"
396
+ This config option is a carryover from v1.
397
+ We originally planned to remove it in v2 but didn't have a 1:1 replacement so we are keeping it for now.
398
+ It is still deprecated and will likely be removed in the future.
399
+ """
400
+
401
+ # new in V2
402
+ strict: bool
403
+ """
404
+ _(new in V2)_ If `True`, strict validation is applied to all fields on the model.
405
+
406
+ By default, Pydantic attempts to coerce values to the correct type, when possible.
407
+
408
+ There are situations in which you may want to disable this behavior, and instead raise an error if a value's type
409
+ does not match the field's type annotation.
410
+
411
+ To configure strict mode for all fields on a model, you can set `strict=True` on the model.
412
+
413
+ ```py
414
+ from pydantic import BaseModel, ConfigDict
415
+
416
+ class Model(BaseModel):
417
+ model_config = ConfigDict(strict=True)
418
+
419
+ name: str
420
+ age: int
421
+ ```
422
+
423
+ See [Strict Mode](../concepts/strict_mode.md) for more details.
424
+
425
+ See the [Conversion Table](../concepts/conversion_table.md) for more details on how Pydantic converts data in both
426
+ strict and lax modes.
427
+ """
428
+ # whether instances of models and dataclasses (including subclass instances) should re-validate, default 'never'
429
+ revalidate_instances: Literal['always', 'never', 'subclass-instances']
430
+ """
431
+ When and how to revalidate models and dataclasses during validation. Accepts the string
432
+ values of `'never'`, `'always'` and `'subclass-instances'`. Defaults to `'never'`.
433
+
434
+ - `'never'` will not revalidate models and dataclasses during validation
435
+ - `'always'` will revalidate models and dataclasses during validation
436
+ - `'subclass-instances'` will revalidate models and dataclasses during validation if the instance is a
437
+ subclass of the model or dataclass
438
+
439
+ By default, model and dataclass instances are not revalidated during validation.
440
+
441
+ ```py
442
+ from typing import List
443
+
444
+ from pydantic import BaseModel
445
+
446
+ class User(BaseModel, revalidate_instances='never'): # (1)!
447
+ hobbies: List[str]
448
+
449
+ class SubUser(User):
450
+ sins: List[str]
451
+
452
+ class Transaction(BaseModel):
453
+ user: User
454
+
455
+ my_user = User(hobbies=['reading'])
456
+ t = Transaction(user=my_user)
457
+ print(t)
458
+ #> user=User(hobbies=['reading'])
459
+
460
+ my_user.hobbies = [1] # (2)!
461
+ t = Transaction(user=my_user) # (3)!
462
+ print(t)
463
+ #> user=User(hobbies=[1])
464
+
465
+ my_sub_user = SubUser(hobbies=['scuba diving'], sins=['lying'])
466
+ t = Transaction(user=my_sub_user)
467
+ print(t)
468
+ #> user=SubUser(hobbies=['scuba diving'], sins=['lying'])
469
+ ```
470
+
471
+ 1. `revalidate_instances` is set to `'never'` by **default.
472
+ 2. The assignment is not validated, unless you set `validate_assignment` to `True` in the model's config.
473
+ 3. Since `revalidate_instances` is set to `never`, this is not revalidated.
474
+
475
+ If you want to revalidate instances during validation, you can set `revalidate_instances` to `'always'`
476
+ in the model's config.
477
+
478
+ ```py
479
+ from typing import List
480
+
481
+ from pydantic import BaseModel, ValidationError
482
+
483
+ class User(BaseModel, revalidate_instances='always'): # (1)!
484
+ hobbies: List[str]
485
+
486
+ class SubUser(User):
487
+ sins: List[str]
488
+
489
+ class Transaction(BaseModel):
490
+ user: User
491
+
492
+ my_user = User(hobbies=['reading'])
493
+ t = Transaction(user=my_user)
494
+ print(t)
495
+ #> user=User(hobbies=['reading'])
496
+
497
+ my_user.hobbies = [1]
498
+ try:
499
+ t = Transaction(user=my_user) # (2)!
500
+ except ValidationError as e:
501
+ print(e)
502
+ '''
503
+ 1 validation error for Transaction
504
+ user.hobbies.0
505
+ Input should be a valid string [type=string_type, input_value=1, input_type=int]
506
+ '''
507
+
508
+ my_sub_user = SubUser(hobbies=['scuba diving'], sins=['lying'])
509
+ t = Transaction(user=my_sub_user)
510
+ print(t) # (3)!
511
+ #> user=User(hobbies=['scuba diving'])
512
+ ```
513
+
514
+ 1. `revalidate_instances` is set to `'always'`.
515
+ 2. The model is revalidated, since `revalidate_instances` is set to `'always'`.
516
+ 3. Using `'never'` we would have gotten `user=SubUser(hobbies=['scuba diving'], sins=['lying'])`.
517
+
518
+ It's also possible to set `revalidate_instances` to `'subclass-instances'` to only revalidate instances
519
+ of subclasses of the model.
520
+
521
+ ```py
522
+ from typing import List
523
+
524
+ from pydantic import BaseModel
525
+
526
+ class User(BaseModel, revalidate_instances='subclass-instances'): # (1)!
527
+ hobbies: List[str]
528
+
529
+ class SubUser(User):
530
+ sins: List[str]
531
+
532
+ class Transaction(BaseModel):
533
+ user: User
534
+
535
+ my_user = User(hobbies=['reading'])
536
+ t = Transaction(user=my_user)
537
+ print(t)
538
+ #> user=User(hobbies=['reading'])
539
+
540
+ my_user.hobbies = [1]
541
+ t = Transaction(user=my_user) # (2)!
542
+ print(t)
543
+ #> user=User(hobbies=[1])
544
+
545
+ my_sub_user = SubUser(hobbies=['scuba diving'], sins=['lying'])
546
+ t = Transaction(user=my_sub_user)
547
+ print(t) # (3)!
548
+ #> user=User(hobbies=['scuba diving'])
549
+ ```
550
+
551
+ 1. `revalidate_instances` is set to `'subclass-instances'`.
552
+ 2. This is not revalidated, since `my_user` is not a subclass of `User`.
553
+ 3. Using `'never'` we would have gotten `user=SubUser(hobbies=['scuba diving'], sins=['lying'])`.
554
+ """
555
+
556
+ ser_json_timedelta: Literal['iso8601', 'float']
557
+ """
558
+ The format of JSON serialized timedeltas. Accepts the string values of `'iso8601'` and
559
+ `'float'`. Defaults to `'iso8601'`.
560
+
561
+ - `'iso8601'` will serialize timedeltas to ISO 8601 durations.
562
+ - `'float'` will serialize timedeltas to the total number of seconds.
563
+ """
564
+
565
+ ser_json_bytes: Literal['utf8', 'base64']
566
+ """
567
+ The encoding of JSON serialized bytes. Accepts the string values of `'utf8'` and `'base64'`.
568
+ Defaults to `'utf8'`.
569
+
570
+ - `'utf8'` will serialize bytes to UTF-8 strings.
571
+ - `'base64'` will serialize bytes to URL safe base64 strings.
572
+ """
573
+
574
+ ser_json_inf_nan: Literal['null', 'constants']
575
+ """
576
+ The encoding of JSON serialized infinity and NaN float values. Accepts the string values of `'null'` and `'constants'`.
577
+ Defaults to `'null'`.
578
+
579
+ - `'null'` will serialize infinity and NaN values as `null`.
580
+ - `'constants'` will serialize infinity and NaN values as `Infinity` and `NaN`.
581
+ """
582
+
583
+ # whether to validate default values during validation, default False
584
+ validate_default: bool
585
+ """Whether to validate default values during validation. Defaults to `False`."""
586
+
587
+ validate_return: bool
588
+ """whether to validate the return value from call validators. Defaults to `False`."""
589
+
590
+ protected_namespaces: tuple[str, ...]
591
+ """
592
+ A `tuple` of strings that prevent model to have field which conflict with them.
593
+ Defaults to `('model_', )`).
594
+
595
+ Pydantic prevents collisions between model attributes and `BaseModel`'s own methods by
596
+ namespacing them with the prefix `model_`.
597
+
598
+ ```py
599
+ import warnings
600
+
601
+ from pydantic import BaseModel
602
+
603
+ warnings.filterwarnings('error') # Raise warnings as errors
604
+
605
+ try:
606
+
607
+ class Model(BaseModel):
608
+ model_prefixed_field: str
609
+
610
+ except UserWarning as e:
611
+ print(e)
612
+ '''
613
+ Field "model_prefixed_field" has conflict with protected namespace "model_".
614
+
615
+ You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
616
+ '''
617
+ ```
618
+
619
+ You can customize this behavior using the `protected_namespaces` setting:
620
+
621
+ ```py
622
+ import warnings
623
+
624
+ from pydantic import BaseModel, ConfigDict
625
+
626
+ warnings.filterwarnings('error') # Raise warnings as errors
627
+
628
+ try:
629
+
630
+ class Model(BaseModel):
631
+ model_prefixed_field: str
632
+ also_protect_field: str
633
+
634
+ model_config = ConfigDict(
635
+ protected_namespaces=('protect_me_', 'also_protect_')
636
+ )
637
+
638
+ except UserWarning as e:
639
+ print(e)
640
+ '''
641
+ Field "also_protect_field" has conflict with protected namespace "also_protect_".
642
+
643
+ You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ('protect_me_',)`.
644
+ '''
645
+ ```
646
+
647
+ While Pydantic will only emit a warning when an item is in a protected namespace but does not actually have a collision,
648
+ an error _is_ raised if there is an actual collision with an existing attribute:
649
+
650
+ ```py
651
+ from pydantic import BaseModel
652
+
653
+ try:
654
+
655
+ class Model(BaseModel):
656
+ model_validate: str
657
+
658
+ except NameError as e:
659
+ print(e)
660
+ '''
661
+ Field "model_validate" conflicts with member <bound method BaseModel.model_validate of <class 'pydantic.main.BaseModel'>> of protected namespace "model_".
662
+ '''
663
+ ```
664
+ """
665
+
666
+ hide_input_in_errors: bool
667
+ """
668
+ Whether to hide inputs when printing errors. Defaults to `False`.
669
+
670
+ Pydantic shows the input value and type when it raises `ValidationError` during the validation.
671
+
672
+ ```py
673
+ from pydantic import BaseModel, ValidationError
674
+
675
+ class Model(BaseModel):
676
+ a: str
677
+
678
+ try:
679
+ Model(a=123)
680
+ except ValidationError as e:
681
+ print(e)
682
+ '''
683
+ 1 validation error for Model
684
+ a
685
+ Input should be a valid string [type=string_type, input_value=123, input_type=int]
686
+ '''
687
+ ```
688
+
689
+ You can hide the input value and type by setting the `hide_input_in_errors` config to `True`.
690
+
691
+ ```py
692
+ from pydantic import BaseModel, ConfigDict, ValidationError
693
+
694
+ class Model(BaseModel):
695
+ a: str
696
+ model_config = ConfigDict(hide_input_in_errors=True)
697
+
698
+ try:
699
+ Model(a=123)
700
+ except ValidationError as e:
701
+ print(e)
702
+ '''
703
+ 1 validation error for Model
704
+ a
705
+ Input should be a valid string [type=string_type]
706
+ '''
707
+ ```
708
+ """
709
+
710
+ defer_build: bool
711
+ """
712
+ Whether to defer model validator and serializer construction until the first model validation.
713
+
714
+ This can be useful to avoid the overhead of building models which are only
715
+ used nested within other models, or when you want to manually define type namespace via
716
+ [`Model.model_rebuild(_types_namespace=...)`][pydantic.BaseModel.model_rebuild]. Defaults to False.
717
+ """
718
+
719
+ plugin_settings: dict[str, object] | None
720
+ """A `dict` of settings for plugins. Defaults to `None`.
721
+
722
+ See [Pydantic Plugins](../concepts/plugins.md) for details.
723
+ """
724
+
725
+ schema_generator: type[_GenerateSchema] | None
726
+ """
727
+ A custom core schema generator class to use when generating JSON schemas.
728
+ Useful if you want to change the way types are validated across an entire model/schema. Defaults to `None`.
729
+
730
+ The `GenerateSchema` interface is subject to change, currently only the `string_schema` method is public.
731
+
732
+ See [#6737](https://github.com/pydantic/pydantic/pull/6737) for details.
733
+ """
734
+
735
+ json_schema_serialization_defaults_required: bool
736
+ """
737
+ Whether fields with default values should be marked as required in the serialization schema. Defaults to `False`.
738
+
739
+ This ensures that the serialization schema will reflect the fact a field with a default will always be present
740
+ when serializing the model, even though it is not required for validation.
741
+
742
+ However, there are scenarios where this may be undesirable — in particular, if you want to share the schema
743
+ between validation and serialization, and don't mind fields with defaults being marked as not required during
744
+ serialization. See [#7209](https://github.com/pydantic/pydantic/issues/7209) for more details.
745
+
746
+ ```py
747
+ from pydantic import BaseModel, ConfigDict
748
+
749
+ class Model(BaseModel):
750
+ a: str = 'a'
751
+
752
+ model_config = ConfigDict(json_schema_serialization_defaults_required=True)
753
+
754
+ print(Model.model_json_schema(mode='validation'))
755
+ '''
756
+ {
757
+ 'properties': {'a': {'default': 'a', 'title': 'A', 'type': 'string'}},
758
+ 'title': 'Model',
759
+ 'type': 'object',
760
+ }
761
+ '''
762
+ print(Model.model_json_schema(mode='serialization'))
763
+ '''
764
+ {
765
+ 'properties': {'a': {'default': 'a', 'title': 'A', 'type': 'string'}},
766
+ 'required': ['a'],
767
+ 'title': 'Model',
768
+ 'type': 'object',
769
+ }
770
+ '''
771
+ ```
772
+ """
773
+
774
+ json_schema_mode_override: Literal['validation', 'serialization', None]
775
+ """
776
+ If not `None`, the specified mode will be used to generate the JSON schema regardless of what `mode` was passed to
777
+ the function call. Defaults to `None`.
778
+
779
+ This provides a way to force the JSON schema generation to reflect a specific mode, e.g., to always use the
780
+ validation schema.
781
+
782
+ It can be useful when using frameworks (such as FastAPI) that may generate different schemas for validation
783
+ and serialization that must both be referenced from the same schema; when this happens, we automatically append
784
+ `-Input` to the definition reference for the validation schema and `-Output` to the definition reference for the
785
+ serialization schema. By specifying a `json_schema_mode_override` though, this prevents the conflict between
786
+ the validation and serialization schemas (since both will use the specified schema), and so prevents the suffixes
787
+ from being added to the definition references.
788
+
789
+ ```py
790
+ from pydantic import BaseModel, ConfigDict, Json
791
+
792
+ class Model(BaseModel):
793
+ a: Json[int] # requires a string to validate, but will dump an int
794
+
795
+ print(Model.model_json_schema(mode='serialization'))
796
+ '''
797
+ {
798
+ 'properties': {'a': {'title': 'A', 'type': 'integer'}},
799
+ 'required': ['a'],
800
+ 'title': 'Model',
801
+ 'type': 'object',
802
+ }
803
+ '''
804
+
805
+ class ForceInputModel(Model):
806
+ # the following ensures that even with mode='serialization', we
807
+ # will get the schema that would be generated for validation.
808
+ model_config = ConfigDict(json_schema_mode_override='validation')
809
+
810
+ print(ForceInputModel.model_json_schema(mode='serialization'))
811
+ '''
812
+ {
813
+ 'properties': {
814
+ 'a': {
815
+ 'contentMediaType': 'application/json',
816
+ 'contentSchema': {'type': 'integer'},
817
+ 'title': 'A',
818
+ 'type': 'string',
819
+ }
820
+ },
821
+ 'required': ['a'],
822
+ 'title': 'ForceInputModel',
823
+ 'type': 'object',
824
+ }
825
+ '''
826
+ ```
827
+ """
828
+
829
+ coerce_numbers_to_str: bool
830
+ """
831
+ If `True`, enables automatic coercion of any `Number` type to `str` in "lax" (non-strict) mode. Defaults to `False`.
832
+
833
+ Pydantic doesn't allow number types (`int`, `float`, `Decimal`) to be coerced as type `str` by default.
834
+
835
+ ```py
836
+ from decimal import Decimal
837
+
838
+ from pydantic import BaseModel, ConfigDict, ValidationError
839
+
840
+ class Model(BaseModel):
841
+ value: str
842
+
843
+ try:
844
+ print(Model(value=42))
845
+ except ValidationError as e:
846
+ print(e)
847
+ '''
848
+ 1 validation error for Model
849
+ value
850
+ Input should be a valid string [type=string_type, input_value=42, input_type=int]
851
+ '''
852
+
853
+ class Model(BaseModel):
854
+ model_config = ConfigDict(coerce_numbers_to_str=True)
855
+
856
+ value: str
857
+
858
+ repr(Model(value=42).value)
859
+ #> "42"
860
+ repr(Model(value=42.13).value)
861
+ #> "42.13"
862
+ repr(Model(value=Decimal('42.13')).value)
863
+ #> "42.13"
864
+ ```
865
+ """
866
+
867
+ regex_engine: Literal['rust-regex', 'python-re']
868
+ """
869
+ The regex engine to be used for pattern validation.
870
+ Defaults to `'rust-regex'`.
871
+
872
+ - `rust-regex` uses the [`regex`](https://docs.rs/regex) Rust crate,
873
+ which is non-backtracking and therefore more DDoS resistant, but does not support all regex features.
874
+ - `python-re` use the [`re`](https://docs.python.org/3/library/re.html) module,
875
+ which supports all regex features, but may be slower.
876
+
877
+ ```py
878
+ from pydantic import BaseModel, ConfigDict, Field, ValidationError
879
+
880
+ class Model(BaseModel):
881
+ model_config = ConfigDict(regex_engine='python-re')
882
+
883
+ value: str = Field(pattern=r'^abc(?=def)')
884
+
885
+ print(Model(value='abcdef').value)
886
+ #> abcdef
887
+
888
+ try:
889
+ print(Model(value='abxyzcdef'))
890
+ except ValidationError as e:
891
+ print(e)
892
+ '''
893
+ 1 validation error for Model
894
+ value
895
+ String should match pattern '^abc(?=def)' [type=string_pattern_mismatch, input_value='abxyzcdef', input_type=str]
896
+ '''
897
+ ```
898
+ """
899
+
900
+ validation_error_cause: bool
901
+ """
902
+ If `True`, Python exceptions that were part of a validation failure will be shown as an exception group as a cause. Can be useful for debugging. Defaults to `False`.
903
+
904
+ Note:
905
+ Python 3.10 and older don't support exception groups natively. <=3.10, backport must be installed: `pip install exceptiongroup`.
906
+
907
+ Note:
908
+ The structure of validation errors are likely to change in future Pydantic versions. Pydantic offers no guarantees about their structure. Should be used for visual traceback debugging only.
909
+ """
910
+
911
+ use_attribute_docstrings: bool
912
+ '''
913
+ Whether docstrings of attributes (bare string literals immediately following the attribute declaration)
914
+ should be used for field descriptions. Defaults to `False`.
915
+
916
+ ```py
917
+ from pydantic import BaseModel, ConfigDict, Field
918
+
919
+
920
+ class Model(BaseModel):
921
+ model_config = ConfigDict(use_attribute_docstrings=True)
922
+
923
+ x: str
924
+ """
925
+ Example of an attribute docstring
926
+ """
927
+
928
+ y: int = Field(description="Description in Field")
929
+ """
930
+ Description in Field overrides attribute docstring
931
+ """
932
+
933
+
934
+ print(Model.model_fields["x"].description)
935
+ # > Example of an attribute docstring
936
+ print(Model.model_fields["y"].description)
937
+ # > Description in Field
938
+ ```
939
+ This requires the source code of the class to be available at runtime.
940
+
941
+ !!! warning "Usage with `TypedDict`"
942
+ Due to current limitations, attribute docstrings detection may not work as expected when using `TypedDict`
943
+ (in particular when multiple `TypedDict` classes have the same name in the same source file). The behavior
944
+ can be different depending on the Python version used.
945
+ '''
946
+
947
+ cache_strings: bool | Literal['all', 'keys', 'none']
948
+ """
949
+ Whether to cache strings to avoid constructing new Python objects. Defaults to True.
950
+
951
+ Enabling this setting should significantly improve validation performance while increasing memory usage slightly.
952
+
953
+ - `True` or `'all'` (the default): cache all strings
954
+ - `'keys'`: cache only dictionary keys
955
+ - `False` or `'none'`: no caching
956
+
957
+ !!! note
958
+ `True` or `'all'` is required to cache strings during general validation because
959
+ validators don't know if they're in a key or a value.
960
+
961
+ !!! tip
962
+ If repeated strings are rare, it's recommended to use `'keys'` or `'none'` to reduce memory usage,
963
+ as the performance difference is minimal if repeated strings are rare.
964
+ """
965
+
966
+
967
+ _TypeT = TypeVar('_TypeT', bound=type)
968
+
969
+
970
+ def with_config(config: ConfigDict) -> Callable[[_TypeT], _TypeT]:
971
+ """Usage docs: https://docs.pydantic.dev/2.7/concepts/config/#configuration-with-dataclass-from-the-standard-library-or-typeddict
972
+
973
+ A convenience decorator to set a [Pydantic configuration](config.md) on a `TypedDict` or a `dataclass` from the standard library.
974
+
975
+ Although the configuration can be set using the `__pydantic_config__` attribute, it does not play well with type checkers,
976
+ especially with `TypedDict`.
977
+
978
+ !!! example "Usage"
979
+
980
+ ```py
981
+ from typing_extensions import TypedDict
982
+
983
+ from pydantic import ConfigDict, TypeAdapter, with_config
984
+
985
+ @with_config(ConfigDict(str_to_lower=True))
986
+ class Model(TypedDict):
987
+ x: str
988
+
989
+ ta = TypeAdapter(Model)
990
+
991
+ print(ta.validate_python({'x': 'ABC'}))
992
+ #> {'x': 'abc'}
993
+ ```
994
+ """
995
+
996
+ def inner(TypedDictClass: _TypeT, /) -> _TypeT:
997
+ TypedDictClass.__pydantic_config__ = config
998
+ return TypedDictClass
999
+
1000
+ return inner
1001
+
1002
+
1003
+ __getattr__ = getattr_migration(__name__)