File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,8 @@ def model_dump(
145
145
exclude = exclude ,
146
146
exclude_unset = exclude_unset ,
147
147
exclude_defaults = exclude_defaults ,
148
- warnings = warnings ,
148
+ # warnings are not supported in Pydantic v1
149
+ warnings = warnings if PYDANTIC_V2 else True ,
149
150
)
150
151
return cast (
151
152
"dict[str, Any]" ,
Original file line number Diff line number Diff line change @@ -561,6 +561,14 @@ class Model(BaseModel):
561
561
m .model_dump (warnings = False )
562
562
563
563
564
+ def test_compat_method_no_error_for_warnings () -> None :
565
+ class Model (BaseModel ):
566
+ foo : Optional [str ]
567
+
568
+ m = Model (foo = "hello" )
569
+ assert isinstance (model_dump (m , warnings = False ), dict )
570
+
571
+
564
572
def test_to_json () -> None :
565
573
class Model (BaseModel ):
566
574
foo : Optional [str ] = Field (alias = "FOO" , default = None )
You can’t perform that action at this time.
0 commit comments