@@ -257,14 +257,15 @@ def model_dump(
257257 mode : Literal ["json" , "python" ] | str = "python" ,
258258 include : IncEx | None = None ,
259259 exclude : IncEx | None = None ,
260- by_alias : bool = False ,
260+ by_alias : bool | None = None ,
261261 exclude_unset : bool = False ,
262262 exclude_defaults : bool = False ,
263263 exclude_none : bool = False ,
264264 round_trip : bool = False ,
265265 warnings : bool | Literal ["none" , "warn" , "error" ] = True ,
266266 context : dict [str , Any ] | None = None ,
267267 serialize_as_any : bool = False ,
268+ fallback : Callable [[Any ], Any ] | None = None ,
268269 ) -> dict [str , Any ]:
269270 """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump
270271
@@ -296,10 +297,12 @@ def model_dump(
296297 raise ValueError ("context is only supported in Pydantic v2" )
297298 if serialize_as_any != False :
298299 raise ValueError ("serialize_as_any is only supported in Pydantic v2" )
300+ if fallback is not None :
301+ raise ValueError ("fallback is only supported in Pydantic v2" )
299302 dumped = super ().dict ( # pyright: ignore[reportDeprecated]
300303 include = include ,
301304 exclude = exclude ,
302- by_alias = by_alias ,
305+ by_alias = by_alias if by_alias is not None else False ,
303306 exclude_unset = exclude_unset ,
304307 exclude_defaults = exclude_defaults ,
305308 exclude_none = exclude_none ,
@@ -314,13 +317,14 @@ def model_dump_json(
314317 indent : int | None = None ,
315318 include : IncEx | None = None ,
316319 exclude : IncEx | None = None ,
317- by_alias : bool = False ,
320+ by_alias : bool | None = None ,
318321 exclude_unset : bool = False ,
319322 exclude_defaults : bool = False ,
320323 exclude_none : bool = False ,
321324 round_trip : bool = False ,
322325 warnings : bool | Literal ["none" , "warn" , "error" ] = True ,
323326 context : dict [str , Any ] | None = None ,
327+ fallback : Callable [[Any ], Any ] | None = None ,
324328 serialize_as_any : bool = False ,
325329 ) -> str :
326330 """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json
@@ -349,11 +353,13 @@ def model_dump_json(
349353 raise ValueError ("context is only supported in Pydantic v2" )
350354 if serialize_as_any != False :
351355 raise ValueError ("serialize_as_any is only supported in Pydantic v2" )
356+ if fallback is not None :
357+ raise ValueError ("fallback is only supported in Pydantic v2" )
352358 return super ().json ( # type: ignore[reportDeprecated]
353359 indent = indent ,
354360 include = include ,
355361 exclude = exclude ,
356- by_alias = by_alias ,
362+ by_alias = by_alias if by_alias is not None else False ,
357363 exclude_unset = exclude_unset ,
358364 exclude_defaults = exclude_defaults ,
359365 exclude_none = exclude_none ,
0 commit comments