@@ -477,7 +477,7 @@ def Relationship(
477
477
class SQLModelMetaclass (ModelMetaclass , DeclarativeMeta ):
478
478
__sqlmodel_relationships__ : Dict [str , RelationshipInfo ]
479
479
model_config : SQLModelConfig
480
- model_fields : Dict [str , FieldInfo ] # type: ignore[assignment ]
480
+ model_fields : ClassVar [ Dict [str , FieldInfo ]]
481
481
__config__ : Type [SQLModelConfig ]
482
482
__fields__ : Dict [str , ModelField ] # type: ignore[assignment]
483
483
@@ -839,7 +839,7 @@ def __tablename__(cls) -> str:
839
839
return cls .__name__ .lower ()
840
840
841
841
@classmethod
842
- def model_validate (
842
+ def model_validate ( # type: ignore[override]
843
843
cls : Type [_TSQLModel ],
844
844
obj : Any ,
845
845
* ,
@@ -863,20 +863,25 @@ def model_dump(
863
863
mode : Union [Literal ["json" , "python" ], str ] = "python" ,
864
864
include : Union [IncEx , None ] = None ,
865
865
exclude : Union [IncEx , None ] = None ,
866
- context : Union [Dict [ str , Any ] , None ] = None ,
867
- by_alias : bool = False ,
866
+ context : Union [Any , None ] = None ,
867
+ by_alias : Union [ bool , None ] = None ,
868
868
exclude_unset : bool = False ,
869
869
exclude_defaults : bool = False ,
870
870
exclude_none : bool = False ,
871
871
round_trip : bool = False ,
872
872
warnings : Union [bool , Literal ["none" , "warn" , "error" ]] = True ,
873
+ fallback : Union [Callable [[Any ], Any ], None ] = None ,
873
874
serialize_as_any : bool = False ,
874
875
) -> Dict [str , Any ]:
876
+ if PYDANTIC_MINOR_VERSION < (2 , 11 ):
877
+ by_alias = by_alias or False
875
878
if PYDANTIC_MINOR_VERSION >= (2 , 7 ):
876
879
extra_kwargs : Dict [str , Any ] = {
877
880
"context" : context ,
878
881
"serialize_as_any" : serialize_as_any ,
879
882
}
883
+ if PYDANTIC_MINOR_VERSION >= (2 , 11 ):
884
+ extra_kwargs ["fallback" ] = fallback
880
885
else :
881
886
extra_kwargs = {}
882
887
if IS_PYDANTIC_V2 :
@@ -896,7 +901,7 @@ def model_dump(
896
901
return super ().dict (
897
902
include = include ,
898
903
exclude = exclude ,
899
- by_alias = by_alias ,
904
+ by_alias = by_alias or False ,
900
905
exclude_unset = exclude_unset ,
901
906
exclude_defaults = exclude_defaults ,
902
907
exclude_none = exclude_none ,
0 commit comments