Skip to content

Commit c7c687c

Browse files
committed
adjust function signatures
1 parent a91ce83 commit c7c687c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

sqlmodel/_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def set_config_value(
103103
model.model_config[parameter] = value # type: ignore[literal-required]
104104

105105
def get_model_fields(model: InstanceOrType[BaseModel]) -> Dict[str, "FieldInfo"]:
106-
return model.model_fields # type: ignore[arg-type]
106+
return model.model_fields
107107

108108
def get_fields_set(
109109
object: InstanceOrType["SQLModel"],

sqlmodel/main.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -839,15 +839,16 @@ def __tablename__(cls) -> str:
839839
return cls.__name__.lower()
840840

841841
@classmethod
842-
def model_validate( # type: ignore[override]
842+
def model_validate(
843843
cls: Type[_TSQLModel],
844844
obj: Any,
845845
*,
846846
strict: Union[bool, None] = None,
847847
from_attributes: Union[bool, None] = None,
848848
context: Union[Dict[str, Any], None] = None,
849-
update: Union[Dict[str, Any], None] = None,
849+
**kwargs: Any,
850850
) -> _TSQLModel:
851+
update = kwargs.get("update", None)
851852
return sqlmodel_validate(
852853
cls=cls,
853854
obj=obj,
@@ -857,25 +858,28 @@ def model_validate( # type: ignore[override]
857858
update=update,
858859
)
859860

860-
def model_dump( # type: ignore[override]
861+
def model_dump(
861862
self,
862863
*,
863864
mode: Union[Literal["json", "python"], str] = "python",
864865
include: Union[IncEx, None] = None,
865866
exclude: Union[IncEx, None] = None,
866-
context: Union[Dict[str, Any], None] = None,
867-
by_alias: bool = False,
867+
context: Union[Any, None] = None,
868+
by_alias: Union[bool, None] = False,
868869
exclude_unset: bool = False,
869870
exclude_defaults: bool = False,
870871
exclude_none: bool = False,
871872
round_trip: bool = False,
872873
warnings: Union[bool, Literal["none", "warn", "error"]] = True,
874+
fallback: Callable[[Any], Any] | None = ...,
873875
serialize_as_any: bool = False,
874876
) -> Dict[str, Any]:
875877
if PYDANTIC_MINOR_VERSION >= (2, 7):
878+
assert isinstance(context, Dict)
876879
extra_kwargs: Dict[str, Any] = {
877880
"context": context,
878881
"serialize_as_any": serialize_as_any,
882+
"fallback": fallback,
879883
}
880884
else:
881885
extra_kwargs = {}
@@ -893,6 +897,7 @@ def model_dump( # type: ignore[override]
893897
**extra_kwargs,
894898
)
895899
else:
900+
assert by_alias is not None
896901
return super().dict(
897902
include=include,
898903
exclude=exclude,

0 commit comments

Comments
 (0)