aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/serializers.py
diff options
context:
space:
mode:
authorGravatar RohanJnr <[email protected]>2021-11-05 10:56:01 +0530
committerGravatar RohanJnr <[email protected]>2021-11-05 10:56:01 +0530
commit41ec1fd7e3d5bd7b0c16a32b5977d46ce5b3e89e (patch)
treef7a9b95065a855f23fbbd3f89ca502d5ad216a52 /pydis_site/apps/api/serializers.py
parentUpdate test cases to adhere to recent changes made that removed hosts. (diff)
Eliminate usage of typing module and update docstrings.
Diffstat (limited to 'pydis_site/apps/api/serializers.py')
-rw-r--r--pydis_site/apps/api/serializers.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/pydis_site/apps/api/serializers.py b/pydis_site/apps/api/serializers.py
index 957c85f3..9b351be2 100644
--- a/pydis_site/apps/api/serializers.py
+++ b/pydis_site/apps/api/serializers.py
@@ -1,6 +1,4 @@
"""Converters from Django models to data interchange formats and back."""
-from typing import List
-
from django.db.models.query import QuerySet
from django.db.utils import IntegrityError
from rest_framework.exceptions import NotFound
@@ -205,12 +203,12 @@ class ExpandedInfractionSerializer(InfractionSerializer):
class OffTopicChannelNameListSerializer(ListSerializer):
"""Custom ListSerializer to override to_representation() when list views are triggered."""
- def to_representation(self, objects: List[OffTopicChannelName]) -> List[str]:
+ def to_representation(self, objects: list[OffTopicChannelName]) -> list[str]:
"""
- Return a list representing a list of `OffTopicChannelName`.
+ Return a list with all `OffTopicChannelName`s in the database.
- This only returns the name of the off topic channel name. As the model
- only has a single attribute, it is unnecessary to create a nested dictionary.
+ This returns the list of off topic channel names. We want to only return
+ the name attribute, hence it is unnecessary to create a nested dictionary.
Additionally, this allows off topic channel name routes to simply return an
array of names instead of objects, saving on bandwidth.
"""