@@ -260,20 +260,22 @@ class MyModel(BaseModel):
260
260
@parametrize
261
261
@pytest .mark .asyncio
262
262
async def test_pydantic_model_to_dictionary (use_async : bool ) -> None :
263
- assert await transform (MyModel (foo = "hi!" ), Any , use_async ) == {"foo" : "hi!" }
264
- assert await transform (MyModel .construct (foo = "hi!" ), Any , use_async ) == {"foo" : "hi!" }
263
+ assert cast ( Any , await transform (MyModel (foo = "hi!" ), Any , use_async ) ) == {"foo" : "hi!" }
264
+ assert cast ( Any , await transform (MyModel .construct (foo = "hi!" ), Any , use_async ) ) == {"foo" : "hi!" }
265
265
266
266
267
267
@parametrize
268
268
@pytest .mark .asyncio
269
269
async def test_pydantic_empty_model (use_async : bool ) -> None :
270
- assert await transform (MyModel .construct (), Any , use_async ) == {}
270
+ assert cast ( Any , await transform (MyModel .construct (), Any , use_async ) ) == {}
271
271
272
272
273
273
@parametrize
274
274
@pytest .mark .asyncio
275
275
async def test_pydantic_unknown_field (use_async : bool ) -> None :
276
- assert await transform (MyModel .construct (my_untyped_field = True ), Any , use_async ) == {"my_untyped_field" : True }
276
+ assert cast (Any , await transform (MyModel .construct (my_untyped_field = True ), Any , use_async )) == {
277
+ "my_untyped_field" : True
278
+ }
277
279
278
280
279
281
@parametrize
@@ -285,7 +287,7 @@ async def test_pydantic_mismatched_types(use_async: bool) -> None:
285
287
params = await transform (model , Any , use_async )
286
288
else :
287
289
params = await transform (model , Any , use_async )
288
- assert params == {"foo" : True }
290
+ assert cast ( Any , params ) == {"foo" : True }
289
291
290
292
291
293
@parametrize
@@ -297,7 +299,7 @@ async def test_pydantic_mismatched_object_type(use_async: bool) -> None:
297
299
params = await transform (model , Any , use_async )
298
300
else :
299
301
params = await transform (model , Any , use_async )
300
- assert params == {"foo" : {"hello" : "world" }}
302
+ assert cast ( Any , params ) == {"foo" : {"hello" : "world" }}
301
303
302
304
303
305
class ModelNestedObjects (BaseModel ):
@@ -309,7 +311,7 @@ class ModelNestedObjects(BaseModel):
309
311
async def test_pydantic_nested_objects (use_async : bool ) -> None :
310
312
model = ModelNestedObjects .construct (nested = {"foo" : "stainless" })
311
313
assert isinstance (model .nested , MyModel )
312
- assert await transform (model , Any , use_async ) == {"nested" : {"foo" : "stainless" }}
314
+ assert cast ( Any , await transform (model , Any , use_async ) ) == {"nested" : {"foo" : "stainless" }}
313
315
314
316
315
317
class ModelWithDefaultField (BaseModel ):
@@ -325,19 +327,19 @@ async def test_pydantic_default_field(use_async: bool) -> None:
325
327
model = ModelWithDefaultField .construct ()
326
328
assert model .with_none_default is None
327
329
assert model .with_str_default == "foo"
328
- assert await transform (model , Any , use_async ) == {}
330
+ assert cast ( Any , await transform (model , Any , use_async ) ) == {}
329
331
330
332
# should be included when the default value is explicitly given
331
333
model = ModelWithDefaultField .construct (with_none_default = None , with_str_default = "foo" )
332
334
assert model .with_none_default is None
333
335
assert model .with_str_default == "foo"
334
- assert await transform (model , Any , use_async ) == {"with_none_default" : None , "with_str_default" : "foo" }
336
+ assert cast ( Any , await transform (model , Any , use_async ) ) == {"with_none_default" : None , "with_str_default" : "foo" }
335
337
336
338
# should be included when a non-default value is explicitly given
337
339
model = ModelWithDefaultField .construct (with_none_default = "bar" , with_str_default = "baz" )
338
340
assert model .with_none_default == "bar"
339
341
assert model .with_str_default == "baz"
340
- assert await transform (model , Any , use_async ) == {"with_none_default" : "bar" , "with_str_default" : "baz" }
342
+ assert cast ( Any , await transform (model , Any , use_async ) ) == {"with_none_default" : "bar" , "with_str_default" : "baz" }
341
343
342
344
343
345
class TypedDictIterableUnion (TypedDict ):
0 commit comments