Skip to content

Commit 6147c7d

Browse files
committed
♻️ Tweak method signatures optimizing for autocompletion and editor support for users
1 parent 2e8be82 commit 6147c7d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

sqlmodel/main.py

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

841841
@classmethod
842-
def model_validate(
842+
def model_validate( # type: ignore[override]
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-
**kwargs: Any,
849+
update: Union[Dict[str, Any], None] = None,
850850
) -> _TSQLModel:
851-
update = kwargs.get("update", None)
852851
return sqlmodel_validate(
853852
cls=cls,
854853
obj=obj,
@@ -865,16 +864,15 @@ def model_dump(
865864
include: Union[IncEx, None] = None,
866865
exclude: Union[IncEx, None] = None,
867866
context: Union[Any, None] = None,
868-
by_alias: Union[bool, None] = False,
867+
by_alias: Union[bool, None] = None,
869868
exclude_unset: bool = False,
870869
exclude_defaults: bool = False,
871870
exclude_none: bool = False,
872871
round_trip: bool = False,
873872
warnings: Union[bool, Literal["none", "warn", "error"]] = True,
873+
fallback: Callable[[Any], Any] | None = None,
874874
serialize_as_any: bool = False,
875-
**kwargs: Any,
876875
) -> Dict[str, Any]:
877-
fallback = kwargs.get("fallback", None)
878876
if PYDANTIC_MINOR_VERSION >= (2, 7):
879877
extra_kwargs: Dict[str, Any] = {
880878
"context": context,
@@ -899,11 +897,10 @@ def model_dump(
899897
**extra_kwargs,
900898
)
901899
else:
902-
assert by_alias is not None
903900
return super().dict(
904901
include=include,
905902
exclude=exclude,
906-
by_alias=by_alias,
903+
by_alias=by_alias or False,
907904
exclude_unset=exclude_unset,
908905
exclude_defaults=exclude_defaults,
909906
exclude_none=exclude_none,

0 commit comments

Comments
 (0)