aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api
diff options
context:
space:
mode:
authorGravatar Jeremiah Boby <[email protected]>2019-07-10 04:16:25 +0100
committerGravatar Jeremiah Boby <[email protected]>2019-07-10 04:16:25 +0100
commitdce0678b6d19fd210a5862b503ae9dcc7b894410 (patch)
tree3dec1435c12bdada903585719ff8b9abc3c1faa7 /pydis_site/apps/api
parentTeach new lint rules to old code (diff)
Give a code a lint
Diffstat (limited to 'pydis_site/apps/api')
-rw-r--r--pydis_site/apps/api/models/bot/bot_setting.py1
-rw-r--r--pydis_site/apps/api/models/bot/documentation_link.py1
-rw-r--r--pydis_site/apps/api/models/bot/infraction.py1
-rw-r--r--pydis_site/apps/api/models/bot/off_topic_channel_name.py1
-rw-r--r--pydis_site/apps/api/models/bot/reminder.py1
-rw-r--r--pydis_site/apps/api/models/bot/role.py1
-rw-r--r--pydis_site/apps/api/models/bot/snake_fact.py1
-rw-r--r--pydis_site/apps/api/models/bot/snake_idiom.py1
-rw-r--r--pydis_site/apps/api/models/bot/snake_name.py1
-rw-r--r--pydis_site/apps/api/models/bot/special_snake.py1
-rw-r--r--pydis_site/apps/api/models/bot/tag.py5
-rw-r--r--pydis_site/apps/api/models/bot/user.py1
-rw-r--r--pydis_site/apps/api/models/utils.py1
-rw-r--r--pydis_site/apps/api/serializers.py4
-rw-r--r--pydis_site/apps/api/views.py1
-rw-r--r--pydis_site/apps/api/viewsets/bot/infraction.py5
-rw-r--r--pydis_site/apps/api/viewsets/bot/nomination.py1
-rw-r--r--pydis_site/apps/api/viewsets/bot/off_topic_channel_name.py4
-rw-r--r--pydis_site/apps/api/viewsets/bot/snake_name.py2
19 files changed, 0 insertions, 34 deletions
diff --git a/pydis_site/apps/api/models/bot/bot_setting.py b/pydis_site/apps/api/models/bot/bot_setting.py
index ee9838b7..a52f3e34 100644
--- a/pydis_site/apps/api/models/bot/bot_setting.py
+++ b/pydis_site/apps/api/models/bot/bot_setting.py
@@ -7,7 +7,6 @@ from pydis_site.apps.api.models.utils import ModelReprMixin
def validate_bot_setting_name(name):
"""Raises a ValidationError if the given name is not a known setting."""
-
known_settings = (
'defcon',
)
diff --git a/pydis_site/apps/api/models/bot/documentation_link.py b/pydis_site/apps/api/models/bot/documentation_link.py
index 30379396..f844ae04 100644
--- a/pydis_site/apps/api/models/bot/documentation_link.py
+++ b/pydis_site/apps/api/models/bot/documentation_link.py
@@ -23,5 +23,4 @@ class DocumentationLink(ModelReprMixin, models.Model):
def __str__(self):
"""Returns the package and URL for the current documentation link, for display purposes."""
-
return f"{self.package} - {self.base_url}"
diff --git a/pydis_site/apps/api/models/bot/infraction.py b/pydis_site/apps/api/models/bot/infraction.py
index 7669352f..da91d6c2 100644
--- a/pydis_site/apps/api/models/bot/infraction.py
+++ b/pydis_site/apps/api/models/bot/infraction.py
@@ -60,7 +60,6 @@ class Infraction(ModelReprMixin, models.Model):
def __str__(self):
"""Returns some info on the current infraction, for display purposes."""
-
s = f"#{self.id}: {self.type} on {self.user_id}"
if self.expires_at:
s += f" until {self.expires_at}"
diff --git a/pydis_site/apps/api/models/bot/off_topic_channel_name.py b/pydis_site/apps/api/models/bot/off_topic_channel_name.py
index 2f55a131..0891f811 100644
--- a/pydis_site/apps/api/models/bot/off_topic_channel_name.py
+++ b/pydis_site/apps/api/models/bot/off_topic_channel_name.py
@@ -16,5 +16,4 @@ class OffTopicChannelName(ModelReprMixin, models.Model):
def __str__(self):
"""Returns the current off-topic name, for display purposes."""
-
return self.name
diff --git a/pydis_site/apps/api/models/bot/reminder.py b/pydis_site/apps/api/models/bot/reminder.py
index ae45b5de..decc9391 100644
--- a/pydis_site/apps/api/models/bot/reminder.py
+++ b/pydis_site/apps/api/models/bot/reminder.py
@@ -42,5 +42,4 @@ class Reminder(ModelReprMixin, models.Model):
def __str__(self):
"""Returns some info on the current reminder, for display purposes."""
-
return f"{self.content} on {self.expiration} by {self.author}"
diff --git a/pydis_site/apps/api/models/bot/role.py b/pydis_site/apps/api/models/bot/role.py
index ad043bd6..34e74009 100644
--- a/pydis_site/apps/api/models/bot/role.py
+++ b/pydis_site/apps/api/models/bot/role.py
@@ -46,5 +46,4 @@ class Role(ModelReprMixin, models.Model):
def __str__(self):
"""Returns the name of the current role, for display purposes."""
-
return self.name
diff --git a/pydis_site/apps/api/models/bot/snake_fact.py b/pydis_site/apps/api/models/bot/snake_fact.py
index c960cbc4..e4486d41 100644
--- a/pydis_site/apps/api/models/bot/snake_fact.py
+++ b/pydis_site/apps/api/models/bot/snake_fact.py
@@ -14,5 +14,4 @@ class SnakeFact(ModelReprMixin, models.Model):
def __str__(self):
"""Returns the current snake fact, for display purposes."""
-
return self.fact
diff --git a/pydis_site/apps/api/models/bot/snake_idiom.py b/pydis_site/apps/api/models/bot/snake_idiom.py
index 0e8f5e94..73ce25eb 100644
--- a/pydis_site/apps/api/models/bot/snake_idiom.py
+++ b/pydis_site/apps/api/models/bot/snake_idiom.py
@@ -14,5 +14,4 @@ class SnakeIdiom(ModelReprMixin, models.Model):
def __str__(self):
"""Returns the current idiom, for display purposes."""
-
return self.idiom
diff --git a/pydis_site/apps/api/models/bot/snake_name.py b/pydis_site/apps/api/models/bot/snake_name.py
index b6ea6202..6d33f872 100644
--- a/pydis_site/apps/api/models/bot/snake_name.py
+++ b/pydis_site/apps/api/models/bot/snake_name.py
@@ -21,5 +21,4 @@ class SnakeName(ModelReprMixin, models.Model):
def __str__(self):
"""Returns the regular and scientific name of the current snake, for display purposes."""
-
return f"{self.name} ({self.scientific})"
diff --git a/pydis_site/apps/api/models/bot/special_snake.py b/pydis_site/apps/api/models/bot/special_snake.py
index 662ff8e3..5d38ab6f 100644
--- a/pydis_site/apps/api/models/bot/special_snake.py
+++ b/pydis_site/apps/api/models/bot/special_snake.py
@@ -24,5 +24,4 @@ class SpecialSnake(ModelReprMixin, models.Model):
def __str__(self):
"""Returns the name of the current snake, for display purposes."""
-
return self.name
diff --git a/pydis_site/apps/api/models/bot/tag.py b/pydis_site/apps/api/models/bot/tag.py
index 99819e42..01b49525 100644
--- a/pydis_site/apps/api/models/bot/tag.py
+++ b/pydis_site/apps/api/models/bot/tag.py
@@ -10,7 +10,6 @@ from pydis_site.apps.api.models.utils import ModelReprMixin
def validate_tag_embed_fields(fields):
"""Raises a ValidationError if any of the given embed fields is invalid."""
-
field_validators = {
'name': (MaxLengthValidator(limit_value=256),),
'value': (MaxLengthValidator(limit_value=1024),)
@@ -30,7 +29,6 @@ def validate_tag_embed_fields(fields):
def validate_tag_embed_footer(footer):
"""Raises a ValidationError if the given footer is invalid."""
-
field_validators = {
'text': (
MinLengthValidator(
@@ -56,7 +54,6 @@ def validate_tag_embed_footer(footer):
def validate_tag_embed_author(author):
"""Raises a ValidationError if the given author is invalid."""
-
field_validators = {
'name': (
MinLengthValidator(
@@ -120,7 +117,6 @@ def validate_tag_embed(embed):
is raised which in turn will allow Django to display errors
as appropriate.
"""
-
all_keys = {
'title', 'type', 'description', 'url', 'timestamp',
'color', 'footer', 'image', 'thumbnail', 'video',
@@ -184,5 +180,4 @@ class Tag(ModelReprMixin, models.Model):
def __str__(self):
"""Returns the title of this tag, for display purposes."""
-
return self.title
diff --git a/pydis_site/apps/api/models/bot/user.py b/pydis_site/apps/api/models/bot/user.py
index 8b995b59..d4deb630 100644
--- a/pydis_site/apps/api/models/bot/user.py
+++ b/pydis_site/apps/api/models/bot/user.py
@@ -50,5 +50,4 @@ class User(ModelReprMixin, models.Model):
def __str__(self):
"""Returns the name and discriminator for the current user, for display purposes."""
-
return f"{self.name}#{self.discriminator}"
diff --git a/pydis_site/apps/api/models/utils.py b/pydis_site/apps/api/models/utils.py
index 8f590392..0540c4de 100644
--- a/pydis_site/apps/api/models/utils.py
+++ b/pydis_site/apps/api/models/utils.py
@@ -6,7 +6,6 @@ class ModelReprMixin:
def __repr__(self):
"""Returns the current model class name and initialisation parameters."""
-
attributes = ' '.join(
f'{attribute}={value!r}'
for attribute, value in sorted(
diff --git a/pydis_site/apps/api/serializers.py b/pydis_site/apps/api/serializers.py
index 905a7f82..19d4ab8c 100644
--- a/pydis_site/apps/api/serializers.py
+++ b/pydis_site/apps/api/serializers.py
@@ -75,7 +75,6 @@ class MessageDeletionContextSerializer(ModelSerializer):
itself, this serializer also allows for passing the `deletedmessage_set` element
which contains messages that were deleted as part of this context.
"""
-
messages = validated_data.pop('deletedmessage_set')
deletion_context = MessageDeletionContext.objects.create(**validated_data)
for message in messages:
@@ -110,7 +109,6 @@ class InfractionSerializer(ModelSerializer):
def validate(self, attrs):
"""Validate data constraints for the given data and abort if it is invalid."""
-
infr_type = attrs.get('type')
expires_at = attrs.get('expires_at')
@@ -133,7 +131,6 @@ class ExpandedInfractionSerializer(InfractionSerializer):
def to_representation(self, instance):
"""Return the dictionary representation of this infraction."""
-
ret = super().to_representation(instance)
user = User.objects.get(id=ret['user'])
@@ -178,7 +175,6 @@ class OffTopicChannelNameSerializer(ModelSerializer):
Additionally, this allows off topic channel name routes to simply return an
array of names instead of objects, saving on bandwidth.
"""
-
return obj.name
diff --git a/pydis_site/apps/api/views.py b/pydis_site/apps/api/views.py
index c7dbf5c8..e79de5e1 100644
--- a/pydis_site/apps/api/views.py
+++ b/pydis_site/apps/api/views.py
@@ -86,7 +86,6 @@ class RulesView(APIView):
ValueError:
If `target` is not `'md'` or `'html'`.
"""
-
if target == 'html':
return f'<a href="{link}">{description}</a>'
elif target == 'md':
diff --git a/pydis_site/apps/api/viewsets/bot/infraction.py b/pydis_site/apps/api/viewsets/bot/infraction.py
index 4be153e1..e1f9c431 100644
--- a/pydis_site/apps/api/viewsets/bot/infraction.py
+++ b/pydis_site/apps/api/viewsets/bot/infraction.py
@@ -124,7 +124,6 @@ class InfractionViewSet(CreateModelMixin, RetrieveModelMixin, ListModelMixin, Ge
def partial_update(self, request, *_args, **_kwargs):
"""Method that handles the nuts and bolts of updating an Infraction."""
-
for field in request.data:
if field in self.frozen_fields:
raise ValidationError({field: ['This field cannot be updated.']})
@@ -143,7 +142,6 @@ class InfractionViewSet(CreateModelMixin, RetrieveModelMixin, ListModelMixin, Ge
Called by the Django Rest Framework in response to the corresponding HTTP request.
"""
-
self.serializer_class = ExpandedInfractionSerializer
return self.list(*args, **kwargs)
@@ -154,7 +152,6 @@ class InfractionViewSet(CreateModelMixin, RetrieveModelMixin, ListModelMixin, Ge
Called by the Django Rest Framework in response to the corresponding HTTP request.
"""
-
self.serializer_class = ExpandedInfractionSerializer
return self.create(*args, **kwargs)
@@ -165,7 +162,6 @@ class InfractionViewSet(CreateModelMixin, RetrieveModelMixin, ListModelMixin, Ge
Called by the Django Rest Framework in response to the corresponding HTTP request.
"""
-
self.serializer_class = ExpandedInfractionSerializer
return self.retrieve(*args, **kwargs)
@@ -176,6 +172,5 @@ class InfractionViewSet(CreateModelMixin, RetrieveModelMixin, ListModelMixin, Ge
Called by the Django Rest Framework in response to the corresponding HTTP request.
"""
-
self.serializer_class = ExpandedInfractionSerializer
return self.partial_update(*args, **kwargs)
diff --git a/pydis_site/apps/api/viewsets/bot/nomination.py b/pydis_site/apps/api/viewsets/bot/nomination.py
index 62f5dd48..dad33056 100644
--- a/pydis_site/apps/api/viewsets/bot/nomination.py
+++ b/pydis_site/apps/api/viewsets/bot/nomination.py
@@ -19,7 +19,6 @@ class NominationViewSet(ModelViewSet):
Called by the Django Rest Framework in response to the corresponding HTTP request.
"""
-
for field in request.data:
if field in self.frozen_fields:
raise ValidationError({field: ['This field cannot be updated.']})
diff --git a/pydis_site/apps/api/viewsets/bot/off_topic_channel_name.py b/pydis_site/apps/api/viewsets/bot/off_topic_channel_name.py
index 4976c291..d977aade 100644
--- a/pydis_site/apps/api/viewsets/bot/off_topic_channel_name.py
+++ b/pydis_site/apps/api/viewsets/bot/off_topic_channel_name.py
@@ -60,14 +60,12 @@ class OffTopicChannelNameViewSet(DestroyModelMixin, ViewSet):
If it doesn't, a HTTP 404 is returned by way of throwing an exception.
"""
-
queryset = self.get_queryset()
name = self.kwargs[self.lookup_field]
return get_object_or_404(queryset, name=name)
def get_queryset(self):
"""Returns a queryset that covers the entire OffTopicChannelName table."""
-
return OffTopicChannelName.objects.all()
def create(self, request):
@@ -76,7 +74,6 @@ class OffTopicChannelNameViewSet(DestroyModelMixin, ViewSet):
Called by the Django Rest Framework in response to the corresponding HTTP request.
"""
-
if 'name' in request.query_params:
create_data = {'name': request.query_params['name']}
serializer = OffTopicChannelNameSerializer(data=create_data)
@@ -95,7 +92,6 @@ class OffTopicChannelNameViewSet(DestroyModelMixin, ViewSet):
Called by the Django Rest Framework in response to the corresponding HTTP request.
"""
-
if 'random_items' in request.query_params:
param = request.query_params['random_items']
try:
diff --git a/pydis_site/apps/api/viewsets/bot/snake_name.py b/pydis_site/apps/api/viewsets/bot/snake_name.py
index 8e63a542..113c6899 100644
--- a/pydis_site/apps/api/viewsets/bot/snake_name.py
+++ b/pydis_site/apps/api/viewsets/bot/snake_name.py
@@ -42,7 +42,6 @@ class SnakeNameViewSet(ViewSet):
def get_queryset(self):
"""Returns a queryset that covers the entire SnakeName table."""
-
return SnakeName.objects.all()
def list(self, request):
@@ -51,7 +50,6 @@ class SnakeNameViewSet(ViewSet):
Called by the Django Rest Framework in response to the corresponding HTTP request.
"""
-
if request.query_params.get('get_all'):
queryset = self.get_queryset()
serialized = self.serializer_class(queryset, many=True)