@@ -89,7 +89,7 @@ class SchemaValidator:
89
89
* ,
90
90
strict : bool | None = None ,
91
91
from_attributes : bool | None = None ,
92
- context : dict [ str , Any ] | None = None ,
92
+ context : Any | None = None ,
93
93
self_instance : Any | None = None ,
94
94
) -> Any :
95
95
"""
@@ -119,7 +119,7 @@ class SchemaValidator:
119
119
* ,
120
120
strict : bool | None = None ,
121
121
from_attributes : bool | None = None ,
122
- context : dict [ str , Any ] | None = None ,
122
+ context : Any | None = None ,
123
123
self_instance : Any | None = None ,
124
124
) -> bool :
125
125
"""
@@ -136,7 +136,7 @@ class SchemaValidator:
136
136
input : str | bytes | bytearray ,
137
137
* ,
138
138
strict : bool | None = None ,
139
- context : dict [ str , Any ] | None = None ,
139
+ context : Any | None = None ,
140
140
self_instance : Any | None = None ,
141
141
) -> Any :
142
142
"""
@@ -163,9 +163,7 @@ class SchemaValidator:
163
163
Returns:
164
164
The validated Python object.
165
165
"""
166
- def validate_strings (
167
- self , input : _StringInput , * , strict : bool | None = None , context : dict [str , Any ] | None = None
168
- ) -> Any :
166
+ def validate_strings (self , input : _StringInput , * , strict : bool | None = None , context : Any | None = None ) -> Any :
169
167
"""
170
168
Validate a string against the schema and return the validated Python object.
171
169
@@ -194,7 +192,7 @@ class SchemaValidator:
194
192
* ,
195
193
strict : bool | None = None ,
196
194
from_attributes : bool | None = None ,
197
- context : dict [ str , Any ] | None = None ,
195
+ context : Any | None = None ,
198
196
) -> dict [str , Any ] | tuple [dict [str , Any ], dict [str , Any ] | None , set [str ]]:
199
197
"""
200
198
Validate an assignment to a field on a model.
@@ -267,7 +265,7 @@ class SchemaSerializer:
267
265
warnings : bool | Literal ['none' , 'warn' , 'error' ] = True ,
268
266
fallback : Callable [[Any ], Any ] | None = None ,
269
267
serialize_as_any : bool = False ,
270
- context : dict [ str , Any ] | None = None ,
268
+ context : Any | None = None ,
271
269
) -> Any :
272
270
"""
273
271
Serialize/marshal a Python object to a Python object including transforming and filtering data.
@@ -313,7 +311,7 @@ class SchemaSerializer:
313
311
warnings : bool | Literal ['none' , 'warn' , 'error' ] = True ,
314
312
fallback : Callable [[Any ], Any ] | None = None ,
315
313
serialize_as_any : bool = False ,
316
- context : dict [ str , Any ] | None = None ,
314
+ context : Any | None = None ,
317
315
) -> bytes :
318
316
"""
319
317
Serialize a Python object to JSON including transforming and filtering data.
@@ -355,11 +353,11 @@ def to_json(
355
353
round_trip : bool = False ,
356
354
timedelta_mode : Literal ['iso8601' , 'float' ] = 'iso8601' ,
357
355
bytes_mode : Literal ['utf8' , 'base64' ] = 'utf8' ,
358
- inf_nan_mode : Literal ['null' , 'constants' ] = 'constants' ,
356
+ inf_nan_mode : Literal ['null' , 'constants' , 'strings' ] = 'constants' ,
359
357
serialize_unknown : bool = False ,
360
358
fallback : Callable [[Any ], Any ] | None = None ,
361
359
serialize_as_any : bool = False ,
362
- context : dict [ str , Any ] | None = None ,
360
+ context : Any | None = None ,
363
361
) -> bytes :
364
362
"""
365
363
Serialize a Python object to JSON including transforming and filtering data.
@@ -376,7 +374,7 @@ def to_json(
376
374
round_trip: Whether to enable serialization and validation round-trip support.
377
375
timedelta_mode: How to serialize `timedelta` objects, either `'iso8601'` or `'float'`.
378
376
bytes_mode: How to serialize `bytes` objects, either `'utf8'` or `'base64'`.
379
- inf_nan_mode: How to serialize `Infinity`, `-Infinity` and `NaN` values, either `'null'` or `'constants '`.
377
+ inf_nan_mode: How to serialize `Infinity`, `-Infinity` and `NaN` values, either `'null'`, `'constants'`, or `'strings '`.
380
378
serialize_unknown: Attempt to serialize unknown types, `str(value)` will be used, if that fails
381
379
`"<Unserializable {value_type} object>"` will be used.
382
380
fallback: A function to call when an unknown value is encountered,
@@ -430,11 +428,11 @@ def to_jsonable_python(
430
428
round_trip : bool = False ,
431
429
timedelta_mode : Literal ['iso8601' , 'float' ] = 'iso8601' ,
432
430
bytes_mode : Literal ['utf8' , 'base64' ] = 'utf8' ,
433
- inf_nan_mode : Literal ['null' , 'constants' ] = 'constants' ,
431
+ inf_nan_mode : Literal ['null' , 'constants' , 'strings' ] = 'constants' ,
434
432
serialize_unknown : bool = False ,
435
433
fallback : Callable [[Any ], Any ] | None = None ,
436
434
serialize_as_any : bool = False ,
437
- context : dict [ str , Any ] | None = None ,
435
+ context : Any | None = None ,
438
436
) -> Any :
439
437
"""
440
438
Serialize/marshal a Python object to a JSON-serializable Python object including transforming and filtering data.
@@ -451,7 +449,7 @@ def to_jsonable_python(
451
449
round_trip: Whether to enable serialization and validation round-trip support.
452
450
timedelta_mode: How to serialize `timedelta` objects, either `'iso8601'` or `'float'`.
453
451
bytes_mode: How to serialize `bytes` objects, either `'utf8'` or `'base64'`.
454
- inf_nan_mode: How to serialize `Infinity`, `-Infinity` and `NaN` values, either `'null'` or `'constants '`.
452
+ inf_nan_mode: How to serialize `Infinity`, `-Infinity` and `NaN` values, either `'null'`, `'constants'`, or `'strings '`.
455
453
serialize_unknown: Attempt to serialize unknown types, `str(value)` will be used, if that fails
456
454
`"<Unserializable {value_type} object>"` will be used.
457
455
fallback: A function to call when an unknown value is encountered,
0 commit comments