Merge pull request #26280 from edx/py-amnesty-course-api

Applied pylint-amnesty to course_api
This commit is contained in:
Jawayria
2021-02-04 14:44:24 +05:00
committed by GitHub
24 changed files with 68 additions and 68 deletions

View File

@@ -1,4 +1,4 @@
""" Course API """
""" Course API """ # lint-amnesty, pylint: disable=django-not-configured
from edx_toggles.toggles import LegacyWaffleSwitch, LegacyWaffleSwitchNamespace

View File

@@ -6,7 +6,7 @@ import logging
from edx_django_utils.monitoring import function_trace
from edx_when.api import get_dates_for_course
from django.conf import settings
from django.contrib.auth.models import AnonymousUser, User
from django.contrib.auth.models import AnonymousUser, User # lint-amnesty, pylint: disable=imported-auth-user
from django.urls import reverse
from rest_framework.exceptions import PermissionDenied
import search
@@ -18,7 +18,7 @@ from lms.djangoapps.courseware.courses import (
get_courses,
get_permission_for_course_about
)
from opaque_keys.edx.django.models import CourseKeyField
from opaque_keys.edx.django.models import CourseKeyField # lint-amnesty, pylint: disable=wrong-import-order
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.lib.api.view_utils import LazySequence
from common.djangoapps.student.models import CourseAccessRole

View File

@@ -3,7 +3,7 @@ Course API Forms
"""
from django.contrib.auth.models import AnonymousUser, User
from django.contrib.auth.models import AnonymousUser, User # lint-amnesty, pylint: disable=imported-auth-user
from django.core.exceptions import ValidationError
from django.forms import CharField, ChoiceField, Form, IntegerField
from django.http import Http404
@@ -48,7 +48,7 @@ class BlockListGetForm(Form):
try:
return int(value)
except ValueError:
raise ValidationError("'{}' is not a valid depth value.".format(value))
raise ValidationError("'{}' is not a valid depth value.".format(value)) # lint-amnesty, pylint: disable=raise-missing-from
def clean_requested_fields(self):
"""
@@ -75,7 +75,7 @@ class BlockListGetForm(Form):
try:
usage_key = UsageKey.from_string(usage_key)
except InvalidKeyError:
raise ValidationError("'{}' is not a valid usage key.".format(str(usage_key)))
raise ValidationError("'{}' is not a valid usage key.".format(str(usage_key))) # lint-amnesty, pylint: disable=raise-missing-from
return usage_key.replace(course_key=modulestore().fill_in_run(usage_key.course_key))
@@ -83,7 +83,7 @@ class BlockListGetForm(Form):
"""
Return cleaned data, including additional requested fields.
"""
cleaned_data = super(BlockListGetForm, self).clean()
cleaned_data = super(BlockListGetForm, self).clean() # lint-amnesty, pylint: disable=super-with-arguments
# Add additional requested_fields that are specified as separate
# parameters, if they were requested.
@@ -224,7 +224,7 @@ class BlockListGetForm(Form):
try:
return User.objects.get(username=requested_username)
except User.DoesNotExist:
raise Http404(
raise Http404( # lint-amnesty, pylint: disable=raise-missing-from
"Requested user '{requested_username}' does not exist.".format(
requested_username=requested_username,
)

View File

@@ -1,7 +1,7 @@
"""
Encapsulates permissions checks for Course Blocks API
"""
from django.contrib.auth.models import User
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from opaque_keys.edx.keys import CourseKey
from lms.djangoapps.courseware.access import has_access
@@ -9,7 +9,7 @@ from lms.djangoapps.courseware.access_response import AccessResponse
from lms.djangoapps.courseware.access_utils import ACCESS_DENIED, ACCESS_GRANTED, check_public_access
from lms.djangoapps.courseware.exceptions import CourseRunNotFound
from lms.djangoapps.courseware.courses import get_course
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview # lint-amnesty, pylint: disable=unused-import
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.roles import CourseStaffRole
from xmodule.course_module import COURSE_VISIBILITY_PUBLIC

View File

@@ -128,7 +128,7 @@ class BlockSerializer(serializers.Serializer): # pylint: disable=abstract-metho
return value if (value is not None) else default
def to_representation(self, block_key):
def to_representation(self, block_key): # lint-amnesty, pylint: disable=arguments-differ
"""
Return a serializable representation of the requested block
"""

View File

@@ -39,7 +39,7 @@ class TestGetBlocks(SharedModuleStoreTestCase):
cls.store.update_item(cls.html_block, ModuleStoreEnum.UserID.test)
def setUp(self):
super(TestGetBlocks, self).setUp()
super(TestGetBlocks, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory.create()
self.request = RequestFactory().get("/dummy")
self.request.user = self.user
@@ -139,7 +139,7 @@ class TestGetBlocksMobileHack(SharedModuleStoreTestCase):
)
def setUp(self):
super(TestGetBlocksMobileHack, self).setUp()
super(TestGetBlocksMobileHack, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory.create()
self.request = RequestFactory().get("/dummy")
self.request.user = self.user
@@ -193,7 +193,7 @@ class TestGetBlocksQueryCountsBase(SharedModuleStoreTestCase):
ENABLED_SIGNALS = ['course_published']
def setUp(self):
super(TestGetBlocksQueryCountsBase, self).setUp()
super(TestGetBlocksQueryCountsBase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory.create()
self.request = RequestFactory().get("/dummy")

View File

@@ -34,7 +34,7 @@ class TestBlockListGetForm(FormTestMixin, SharedModuleStoreTestCase):
cls.course = CourseFactory.create()
def setUp(self):
super(TestBlockListGetForm, self).setUp()
super(TestBlockListGetForm, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.student = UserFactory.create()
self.student2 = UserFactory.create()

View File

@@ -37,7 +37,7 @@ class TestBlockSerializerBase(SharedModuleStoreTestCase):
cls.store.update_item(cls.html_block, ModuleStoreEnum.UserID.test)
def setUp(self):
super(TestBlockSerializerBase, self).setUp()
super(TestBlockSerializerBase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory.create()

View File

@@ -48,7 +48,7 @@ class TestBlocksView(SharedModuleStoreTestCase):
)
def setUp(self):
super(TestBlocksView, self).setUp()
super(TestBlocksView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
# create and enroll user in the toy course
self.user = UserFactory.create()
@@ -402,7 +402,7 @@ class TestBlocksInCourseView(TestBlocksView, CompletionWaffleTestMixin): # pyli
"""
def setUp(self):
super(TestBlocksInCourseView, self).setUp()
super(TestBlocksInCourseView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.url = reverse('blocks_in_course')
self.query_params['course_id'] = str(self.course_key)
self.override_waffle_switch(True)

View File

@@ -21,7 +21,7 @@ class MilestonesAndSpecialExamsTransformer(BlockStructureTransformer):
"""
A transformer that handles both milestones and special (timed) exams.
It includes or excludes all unfulfilled milestones from the student view based on the value of `include_gated_sections`.
It includes or excludes all unfulfilled milestones from the student view based on the value of `include_gated_sections`. # lint-amnesty, pylint: disable=line-too-long
An entrance exam is considered a milestone, and is not considered a "special exam".
@@ -155,13 +155,13 @@ class MilestonesAndSpecialExamsTransformer(BlockStructureTransformer):
if user_can_skip_entrance_exam:
# remove the entrance exam from required content
entrance_exam_id = block_structure.get_xblock_field(block_structure.root_block_usage_key, 'entrance_exam_id')
entrance_exam_id = block_structure.get_xblock_field(block_structure.root_block_usage_key, 'entrance_exam_id') # lint-amnesty, pylint: disable=line-too-long
required_content = [content for content in required_content if not content == entrance_exam_id]
return required_content
@staticmethod
def gated_by_required_content(block_key, block_structure, required_content):
def gated_by_required_content(block_key, block_structure, required_content): # lint-amnesty, pylint: disable=unused-argument
"""
Returns True if the current block associated with the block_key should be gated by the given required_content.
Returns False otherwise.

View File

@@ -36,7 +36,7 @@ class StubCompletableXBlock(XBlock, CompletableXBlockMixin):
XBlock to test behaviour of BlockCompletionTransformer
when transforming completable XBlock.
"""
pass
pass # lint-amnesty, pylint: disable=unnecessary-pass
class BlockCompletionTransformerTestCase(TransformerRegistryTestMixin, CompletionWaffleTestMixin, ModuleStoreTestCase):
@@ -47,7 +47,7 @@ class BlockCompletionTransformerTestCase(TransformerRegistryTestMixin, Completio
COMPLETION_TEST_VALUE = 0.4
def setUp(self):
super(BlockCompletionTransformerTestCase, self).setUp()
super(BlockCompletionTransformerTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory.create(password='test')
# Set ENABLE_COMPLETION_TRACKING waffle switch to True
self.override_waffle_switch(True)

View File

@@ -18,7 +18,7 @@ class TestBlockCountsTransformer(ModuleStoreTestCase):
"""
def setUp(self):
super(TestBlockCountsTransformer, self).setUp()
super(TestBlockCountsTransformer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course_key = SampleCourseFactory.create().id
self.course_usage_key = self.store.make_course_usage_key(self.course_key)
self.block_structure = BlockStructureFactory.create_from_modulestore(self.course_usage_key, self.store)

View File

@@ -30,7 +30,7 @@ class TestExtraFieldsTransformer(ModuleStoreTestCase):
}
def setUp(self):
super(TestExtraFieldsTransformer, self).setUp()
super(TestExtraFieldsTransformer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = SampleCourseFactory.create(
other_course_settings=self.OTHER_COURSE_SETTINGS_DEFAULT

View File

@@ -30,7 +30,7 @@ class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseM
"""
Setup course structure and create user for split test transformer test.
"""
super(MilestonesTransformerTestCase, self).setUp()
super(MilestonesTransformerTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
# Build course.
self.course_hierarchy = self.get_course_hierarchy()
@@ -198,8 +198,8 @@ class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseM
self.course.enable_subsection_gating = True
self.setup_gated_section(self.blocks['H'], self.blocks['A'])
expected_blocks = (
'course', 'A', 'B', 'C', 'ProctoredExam', 'D', 'E', 'PracticeExam', 'F', 'G', 'TimedExam', 'J', 'K', 'H', 'I'
)
'course', 'A', 'B', 'C', 'ProctoredExam', 'D', 'E', 'PracticeExam', 'F', 'G', 'TimedExam', 'J', 'K', 'H',
'I') # lint-amnesty, pylint: disable=line-too-long
self.get_blocks_and_check_against_expected(self.user, expected_blocks)
# clear the request cache to simulate a new request
self.clear_caches()

View File

@@ -20,7 +20,7 @@ class TestStudentViewTransformer(ModuleStoreTestCase):
"""
def setUp(self):
super(TestStudentViewTransformer, self).setUp()
super(TestStudentViewTransformer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course_key = ToyCourseFactory.create().id
self.course_usage_key = self.store.make_course_usage_key(self.course_key)
self.block_structure = BlockStructureFactory.create_from_modulestore(self.course_usage_key, self.store)

View File

@@ -20,7 +20,7 @@ class TestVideoBlockURLTransformer(ModuleStoreTestCase):
"""
def setUp(self):
super(TestVideoBlockURLTransformer, self).setUp()
super(TestVideoBlockURLTransformer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course_key = ToyCourseFactory.create().id
self.course_usage_key = self.store.make_course_usage_key(self.course_key)
self.block_structure = BlockStructureFactory.create_from_modulestore(self.course_usage_key, self.store)

View File

@@ -238,7 +238,7 @@ class BlocksView(DeveloperErrorViewMixin, ListAPIView):
patch_response_headers(response)
return response
except ItemNotFoundError as exception:
raise Http404(u"Block not found: {}".format(text_type(exception)))
raise Http404(u"Block not found: {}".format(text_type(exception))) # lint-amnesty, pylint: disable=raise-missing-from
@view_auth_classes(is_authenticated=False)
@@ -301,9 +301,9 @@ class BlocksInCourseView(BlocksView):
course_key = CourseKey.from_string(course_key_string)
course_usage_key = modulestore().make_course_usage_key(course_key)
except InvalidKeyError:
raise ValidationError(u"'{}' is not a valid course key.".format(six.text_type(course_key_string)))
raise ValidationError(u"'{}' is not a valid course key.".format(six.text_type(course_key_string))) # lint-amnesty, pylint: disable=raise-missing-from
response = super().list(request, course_usage_key,
hide_access_denials=hide_access_denials)
hide_access_denials=hide_access_denials) # lint-amnesty, pylint: disable=super-with-arguments
if 'completion' not in request.query_params.getlist('requested_fields', ''):
return response

View File

@@ -43,7 +43,7 @@ class CourseDetailGetForm(UsernameValidatorMixin, Form):
try:
return CourseKey.from_string(course_key_string)
except InvalidKeyError:
raise ValidationError(u"'{}' is not a valid course key.".format(six.text_type(course_key_string)))
raise ValidationError(u"'{}' is not a valid course key.".format(six.text_type(course_key_string))) # lint-amnesty, pylint: disable=raise-missing-from
class CourseListGetForm(UsernameValidatorMixin, Form):
@@ -65,7 +65,7 @@ class CourseListGetForm(UsernameValidatorMixin, Form):
"""
Return cleaned data, including additional filters.
"""
cleaned_data = super(CourseListGetForm, self).clean()
cleaned_data = super(CourseListGetForm, self).clean() # lint-amnesty, pylint: disable=super-with-arguments
# create a filter for all supported filter fields
filter_ = dict()

View File

@@ -4,14 +4,14 @@ Course API Serializers. Representing course catalog data
from edx_django_utils import monitoring as monitoring_utils
import six.moves.urllib.error
import six.moves.urllib.parse
import six.moves.urllib.request
import six.moves.urllib.error # lint-amnesty, pylint: disable=wrong-import-order
import six.moves.urllib.parse # lint-amnesty, pylint: disable=wrong-import-order
import six.moves.urllib.request # lint-amnesty, pylint: disable=wrong-import-order
from django.urls import reverse
from rest_framework import serializers
from openedx.core.djangoapps.models.course_details import CourseDetails
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview # lint-amnesty, pylint: disable=unused-import
from openedx.core.lib.api.fields import AbsoluteURLField
@@ -21,7 +21,7 @@ class _MediaSerializer(serializers.Serializer): # pylint: disable=abstract-meth
"""
def __init__(self, uri_attribute, *args, **kwargs):
super(_MediaSerializer, self).__init__(*args, **kwargs)
super(_MediaSerializer, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments
self.uri_attribute = uri_attribute
uri = serializers.SerializerMethodField(source='*')
@@ -41,7 +41,7 @@ class _AbsolutMediaSerializer(_MediaSerializer): # pylint: disable=abstract-met
def __call__(self, serializer_field):
self.context = serializer_field.context
return super(self).__call__(serializer_field)
return super(self).__call__(serializer_field) # lint-amnesty, pylint: disable=bad-super-call
uri_absolute = serializers.SerializerMethodField(source="*")
@@ -62,7 +62,7 @@ class _AbsolutMediaSerializer(_MediaSerializer): # pylint: disable=abstract-met
# In order to use the AbsoluteURLField to have the same
# behaviour what ImageSerializer provides, we need to set
# the request for the field
field._context = {"request": self.context.get("request")}
field._context = {"request": self.context.get("request")} # lint-amnesty, pylint: disable=protected-access
return field.to_representation(cdn_applied_uri)

View File

@@ -164,7 +164,7 @@ class TestGetCourseListMultipleCourses(CourseListTestMixin, ModuleStoreTestCase)
ENABLED_SIGNALS = ['course_published']
def setUp(self):
super(TestGetCourseListMultipleCourses, self).setUp()
super(TestGetCourseListMultipleCourses, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = self.create_course(mobile_available=False)
self.staff_user = self.create_user("staff", is_staff=True)
self.honor_user = self.create_user("honor", is_staff=False)

View File

@@ -48,7 +48,7 @@ class TestCourseListGetForm(FormTestMixin, UsernameTestMixin, SharedModuleStoreT
cls.course = CourseFactory.create()
def setUp(self):
super(TestCourseListGetForm, self).setUp()
super(TestCourseListGetForm, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.student = UserFactory.create()
self.set_up_data(self.student)
@@ -100,7 +100,7 @@ class TestCourseListGetForm(FormTestMixin, UsernameTestMixin, SharedModuleStoreT
self.assert_valid(self.cleaned_data)
class TestCourseIdListGetForm(FormTestMixin, UsernameTestMixin, SharedModuleStoreTestCase):
class TestCourseIdListGetForm(FormTestMixin, UsernameTestMixin, SharedModuleStoreTestCase): # lint-amnesty, pylint: disable=missing-class-docstring
FORM_CLASS = CourseIdListGetForm
@classmethod
@@ -110,7 +110,7 @@ class TestCourseIdListGetForm(FormTestMixin, UsernameTestMixin, SharedModuleStor
cls.course = CourseFactory.create()
def setUp(self):
super(TestCourseIdListGetForm, self).setUp()
super(TestCourseIdListGetForm, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.student = UserFactory.create()
self.set_up_data(self.student)
@@ -149,7 +149,7 @@ class TestCourseDetailGetForm(FormTestMixin, UsernameTestMixin, SharedModuleStor
cls.course = CourseFactory.create()
def setUp(self):
super(TestCourseDetailGetForm, self).setUp()
super(TestCourseDetailGetForm, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.student = UserFactory.create()
self.set_up_data(self.student)

View File

@@ -34,7 +34,7 @@ class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase):
ENABLED_SIGNALS = ['course_published']
def setUp(self):
super(TestCourseSerializer, self).setUp()
super(TestCourseSerializer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.staff_user = self.create_user('staff', is_staff=True)
self.honor_user = self.create_user('honor', is_staff=False)
self.request_factory = APIRequestFactory()
@@ -146,7 +146,7 @@ class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase):
self.assertEqual(result['pacing'], expected_pacing)
class TestCourseDetailSerializer(TestCourseSerializer):
class TestCourseDetailSerializer(TestCourseSerializer): # lint-amnesty, pylint: disable=test-inherits-tests
"""
Test CourseDetailSerializer by rerunning all the tests
in TestCourseSerializer, but with the
@@ -158,7 +158,7 @@ class TestCourseDetailSerializer(TestCourseSerializer):
serializer_class = CourseDetailSerializer
def setUp(self):
super(TestCourseDetailSerializer, self).setUp()
super(TestCourseDetailSerializer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
# update the expected_data to include the 'overview' data.
about_descriptor = XBlock.load_class('about')
@@ -166,7 +166,7 @@ class TestCourseDetailSerializer(TestCourseSerializer):
self.expected_data['overview'] = overview_template.get('data')
class TestCourseKeySerializer(TestCase):
class TestCourseKeySerializer(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
def test_course_key_serializer(self):
course_key = CourseLocator(org='org', course='course', run='2020_Q3')

View File

@@ -22,7 +22,7 @@ from waffle.testutils import override_switch
from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
from opaque_keys.edx.locator import LibraryLocator
from opaque_keys.edx.locator import LibraryLocator # lint-amnesty, pylint: disable=wrong-import-order
from openedx.core.lib.api.view_utils import LazySequence
from openedx.features.content_type_gating.models import ContentTypeGatingConfig
from openedx.features.course_duration_limits.models import CourseDurationLimitConfig
@@ -160,7 +160,7 @@ class CourseListViewTestCaseMultipleCourses(CourseApiTestViewMixin, ModuleStoreT
ENABLED_SIGNALS = ['course_published']
def setUp(self):
super(CourseListViewTestCaseMultipleCourses, self).setUp()
super(CourseListViewTestCaseMultipleCourses, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = self.create_course(mobile_available=False)
self.url = reverse('course-list')
self.staff_user = self.create_user(username='staff', is_staff=True)
@@ -298,7 +298,7 @@ class CourseListSearchViewTest(CourseApiTestViewMixin, ModuleStoreTestCase, Sear
ENABLED_CACHES = ModuleStoreTestCase.ENABLED_CACHES + ['configuration']
def setUp(self):
super(CourseListSearchViewTest, self).setUp()
super(CourseListSearchViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
DemoCourse.reset_count()
self.searcher.destroy()
@@ -422,7 +422,7 @@ class CourseIdListViewTestCase(CourseApiTestViewMixin, ModuleStoreTestCase):
ENABLED_SIGNALS = ['course_published']
def setUp(self):
super(CourseIdListViewTestCase, self).setUp()
super(CourseIdListViewTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = self.create_course()
self.url = reverse('course-id-list')
self.staff_user = self.create_user(username='staff', is_staff=True)
@@ -535,7 +535,7 @@ class CourseIdListViewTestCase(CourseApiTestViewMixin, ModuleStoreTestCase):
self.assertTrue(filtered_response.data['results'][0].startswith(self.course.org))
class LazyPageNumberPaginationTestCase(TestCase):
class LazyPageNumberPaginationTestCase(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
def test_lazy_page_number_pagination(self):
number_sequence = range(20)

View File

@@ -138,7 +138,7 @@ class CourseListUserThrottle(UserRateThrottle):
'staff': '40/minute',
}
def check_for_switches(self):
def check_for_switches(self): # lint-amnesty, pylint: disable=missing-function-docstring
if USE_RATE_LIMIT_2_FOR_COURSE_LIST_API.is_enabled():
self.THROTTLE_RATES = {
'user': '2/minute',
@@ -159,7 +159,7 @@ class CourseListUserThrottle(UserRateThrottle):
self.rate = self.get_rate()
self.num_requests, self.duration = self.parse_rate(self.rate)
return super(CourseListUserThrottle, self).allow_request(request, view)
return super(CourseListUserThrottle, self).allow_request(request, view) # lint-amnesty, pylint: disable=super-with-arguments
class LazyPageNumberPagination(NamespacedPageNumberPagination):
@@ -191,9 +191,9 @@ class LazyPageNumberPagination(NamespacedPageNumberPagination):
page_number=page_number, message=str(exc)
)
self.page.number = self.page.paginator.num_pages
raise NotFound(msg)
raise NotFound(msg) # lint-amnesty, pylint: disable=raise-missing-from
return super(LazyPageNumberPagination, self).get_paginated_response(data)
return super(LazyPageNumberPagination, self).get_paginated_response(data) # lint-amnesty, pylint: disable=super-with-arguments
@function_trace('pagination_paginate_queryset')
def paginate_queryset(self, queryset, request, view=None):
@@ -220,19 +220,19 @@ class LazyPageNumberPagination(NamespacedPageNumberPagination):
with function_trace('pagination_paginate_queryset_get_page'):
try:
self.page = paginator.page(page_number)
self.page = paginator.page(page_number) # lint-amnesty, pylint: disable=attribute-defined-outside-init
except InvalidPage as exc:
msg = self.invalid_page_message.format(
page_number=page_number, message=str(exc)
)
raise NotFound(msg)
raise NotFound(msg) # lint-amnesty, pylint: disable=raise-missing-from
with function_trace('pagination_paginate_queryset_get_num_pages'):
if paginator.num_pages > 1 and self.template is not None:
# The browsable API should display pagination controls.
self.display_page_controls = True
self.request = request
self.request = request # lint-amnesty, pylint: disable=attribute-defined-outside-init
with function_trace('pagination_paginate_queryset_listify_page'):
page_list = list(self.page)
@@ -347,7 +347,7 @@ class CourseIdListUserThrottle(UserRateThrottle):
self.rate = self.get_rate()
self.num_requests, self.duration = self.parse_rate(self.rate)
return super(CourseIdListUserThrottle, self).allow_request(request, view)
return super(CourseIdListUserThrottle, self).allow_request(request, view) # lint-amnesty, pylint: disable=super-with-arguments
@view_auth_classes()
@@ -434,7 +434,7 @@ class CourseIdListView(DeveloperErrorViewMixin, ListAPIView):
This should be called once per GET request.
"""
return super(CourseIdListView, self).paginate_queryset(*args, **kwargs)
return super(CourseIdListView, self).paginate_queryset(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments
@function_trace('get_paginated_response')
def get_paginated_response(self, *args, **kwargs):
@@ -446,7 +446,7 @@ class CourseIdListView(DeveloperErrorViewMixin, ListAPIView):
means two GET requests and one function call per request. Otherwise, if
the whole response fits in one page, this function never gets called.
"""
return super(CourseIdListView, self).get_paginated_response(*args, **kwargs)
return super(CourseIdListView, self).get_paginated_response(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments
@function_trace('filter_queryset')
def filter_queryset(self, *args, **kwargs):
@@ -456,7 +456,7 @@ class CourseIdListView(DeveloperErrorViewMixin, ListAPIView):
This should be called once per GET request.
"""
return super(CourseIdListView, self).filter_queryset(*args, **kwargs)
return super(CourseIdListView, self).filter_queryset(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments
@function_trace('get_serializer')
def get_serializer(self, *args, **kwargs):
@@ -466,4 +466,4 @@ class CourseIdListView(DeveloperErrorViewMixin, ListAPIView):
This should be called once per GET request.
"""
return super(CourseIdListView, self).get_serializer(*args, **kwargs)
return super(CourseIdListView, self).get_serializer(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments