Skip to content

Commit

Permalink
Fixes mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dtiesling committed Dec 19, 2023
1 parent 7326d91 commit ff6bb07
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/flask_muck/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def serialize_model_instance(instance: SqlaModel, serializer: Serializer) -> Jso
if issubclass(serializer, Schema):
return serializer().dump(instance)
elif issubclass(serializer, BaseModel):
return serializer.model_validate(instance, from_attributes=True).model_dump() # type: ignore
return serializer.model_validate(instance, from_attributes=True).model_dump()
else:
raise TypeError(
f"Schemas must be Marshmallow Schemas or Pydantic BaseModels. {serializer} is a {type(serializer)}"
Expand All @@ -98,7 +98,7 @@ def serialize_model_instance(instance: SqlaModel, serializer: Serializer) -> Jso

def pydantic_model_to_optional(model: type[BaseModel]) -> type[BaseModel]:
"""Returns a new model where all fields are Optional. Used for PATCH JSON payload validation."""
return create_model(
return create_model( # type: ignore
model.__class__.__name__,
**{
name: (Optional[type_], None)
Expand All @@ -117,7 +117,7 @@ def validate_payload(
if partial:
serializer = pydantic_model_to_optional(serializer)
serializer.model_config["from_attributes"] = True
return serializer.model_validate(payload).model_dump() # type: ignore
return serializer.model_validate(payload).model_dump()
else:
raise TypeError(
f"Schemas must be Marshmallow Schemas or Pydantic BaseModels. {serializer} is a {type(serializer)}"
Expand Down

0 comments on commit ff6bb07

Please sign in to comment.