Skip to content

Commit

Permalink
add type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jan 29, 2024
1 parent 2fdbb7b commit 863d197
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion codeforlife/serializers/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Meta:
list_serializer_class = UserListSerializer
"""

instance: t.List[AnyModel]
batch_size: t.Optional[int] = None

@classmethod
Expand Down Expand Up @@ -91,7 +92,11 @@ def create(self, validated_data: t.List[t.Dict[str, t.Any]]):
batch_size=self.batch_size,
)

def update(self, instance, validated_data: t.List[t.Dict[str, t.Any]]):
def update(
self,
instance: t.List[AnyModel],
validated_data: t.List[t.Dict[str, t.Any]],
):
"""Bulk update many instances of a model.
https://www.django-rest-framework.org/api-guide/serializers/#customizing-multiple-update
Expand Down Expand Up @@ -132,3 +137,7 @@ def validate(self, attrs: t.List[t.Dict[str, t.Any]]):
raise _ValidationError("Some models do not exist.")

return attrs

# pylint: disable-next=useless-parent-delegation,arguments-renamed
def to_representation(self, instance: t.List[AnyModel]):
return super().to_representation(instance)

0 comments on commit 863d197

Please sign in to comment.