Skip to content

Commit 105b772

Browse files
committed
style: Fix tox -e quality issues.
1 parent 7e5714d commit 105b772

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed

backend/sample_plugin/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class CourseArchiveStatus(models.Model):
1111
Model to track the archive status of a course.
1212
1313
Stores information about whether a course has been archived and when it was archived.
14-
14+
1515
.. no_pii: This model does not store PII directly, only references to users via foreign keys.
1616
"""
1717

@@ -47,12 +47,14 @@ def __str__(self):
4747
"""
4848
Return a string representation of the course archive status.
4949
"""
50+
# pylint: disable=no-member
5051
return f"{self.course_id} - {self.user.username} - {'Archived' if self.is_archived else 'Not Archived'}"
5152

5253
class Meta:
5354
"""
5455
Meta options for the CourseArchiveStatus model.
5556
"""
57+
5658
verbose_name = "Course Archive Status"
5759
verbose_name_plural = "Course Archive Statuses"
5860
ordering = ["-updated_at"]

backend/sample_plugin/serializers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ class CourseArchiveStatusSerializer(serializers.ModelSerializer):
1010
"""
1111
Serializer for the CourseArchiveStatus model.
1212
"""
13-
13+
1414
class Meta:
1515
"""
1616
Meta class for CourseArchiveStatusSerializer.
1717
"""
18+
1819
model = CourseArchiveStatus
1920
fields = [
2021
'id',
@@ -25,4 +26,4 @@ class Meta:
2526
'created_at',
2627
'updated_at',
2728
]
28-
read_only_fields = ['id', 'created_at', 'updated_at', 'archive_date']
29+
read_only_fields = ['id', 'created_at', 'updated_at', 'archive_date']

backend/sample_plugin/views.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
Views for the sample_plugin app.
33
"""
44
import logging
5+
56
from django.utils import timezone
67
from django_filters.rest_framework import DjangoFilterBackend
8+
from opaque_keys import InvalidKeyError
9+
from opaque_keys.edx.keys import CourseKey
710
from rest_framework import filters, permissions, viewsets
811
from rest_framework.exceptions import PermissionDenied, ValidationError
912
from rest_framework.pagination import PageNumberPagination
10-
from rest_framework.throttling import UserRateThrottle, AnonRateThrottle
13+
from rest_framework.throttling import AnonRateThrottle, UserRateThrottle
1114

1215
from sample_plugin.models import CourseArchiveStatus
1316
from sample_plugin.serializers import CourseArchiveStatusSerializer
1417

15-
1618
logger = logging.getLogger(__name__)
1719

1820

@@ -47,6 +49,7 @@ class CourseArchiveStatusPagination(PageNumberPagination):
4749
"""
4850
Pagination class for CourseArchiveStatus.
4951
"""
52+
5053
page_size = 20
5154
page_size_query_param = 'page_size'
5255
max_page_size = 100
@@ -56,6 +59,7 @@ class CourseArchiveStatusThrottle(UserRateThrottle):
5659
"""
5760
Throttle for the CourseArchiveStatus API.
5861
"""
62+
5963
rate = '60/minute'
6064

6165

@@ -68,6 +72,7 @@ class CourseArchiveStatusViewSet(viewsets.ModelViewSet):
6872
Filtering is available on course_id, user, and is_archived fields.
6973
Ordering is available on all fields.
7074
"""
75+
7176
serializer_class = CourseArchiveStatusSerializer
7277
permission_classes = [IsOwnerOrStaffSuperuser]
7378
pagination_class = CourseArchiveStatusPagination
@@ -120,10 +125,9 @@ def _is_valid_course_id(self, course_id):
120125
sophisticated validator from the edx-platform.
121126
"""
122127
try:
123-
from opaque_keys.edx.keys import CourseKey
124128
CourseKey.from_string(course_id)
125129
return True
126-
except:
130+
except InvalidKeyError:
127131
return False
128132

129133
def perform_create(self, serializer):

backend/tests/__init__.py

Whitespace-only changes.

backend/tests/test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# pylint: disable=redefined-outer-name
23
"""
34
Tests for the `sample-plugin` REST API.
45
"""
@@ -12,7 +13,6 @@
1213

1314
from sample_plugin.models import CourseArchiveStatus
1415

15-
1616
User = get_user_model()
1717

1818

@@ -98,7 +98,7 @@ def test_list_course_archive_status_authenticated(api_client, user, course_archi
9898

9999

100100
@pytest.mark.django_db
101-
def test_list_course_archive_status_unauthenticated(api_client, course_archive_status):
101+
def test_list_course_archive_status_unauthenticated(api_client):
102102
"""
103103
Test that an unauthenticated user cannot list course archive statuses.
104104
"""

backend/tests/test_models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
#!/usr/bin/env python
2+
# pylint: disable=redefined-outer-name
23
"""
34
Tests for the `sample-plugin` models module.
45
"""
56

67
import pytest
78
from django.contrib.auth import get_user_model
89
from django.db.utils import IntegrityError
9-
from opaque_keys.edx.django.models import CourseKeyField
1010
from opaque_keys.edx.keys import CourseKey
1111

1212
from sample_plugin.models import CourseArchiveStatus
1313

14-
1514
User = get_user_model()
1615

1716

0 commit comments

Comments
 (0)