BOM-2281 : Pylint amnesty for grades,gating and instructor app (#26343)

* pyint amnesty for grades,gating and instructor app
This commit is contained in:
M. Zulqarnain
2021-02-03 18:14:35 +05:00
committed by GitHub
parent 185e6c2d76
commit 0213fde968
61 changed files with 198 additions and 194 deletions

View File

@@ -26,7 +26,7 @@ class GradingPolicySerializer(serializers.Serializer):
# When the grader dictionary was missing keys, DRF v2 would default to None;
# DRF v3 unhelpfully raises an exception.
return dict(
super(GradingPolicySerializer, self).to_representation(
super(GradingPolicySerializer, self).to_representation( # lint-amnesty, pylint: disable=super-with-arguments
defaultdict(lambda: None, instance)
)
)

View File

@@ -510,7 +510,7 @@ class GradebookView(GradeViewMixin, PaginatedAPIView):
@verify_course_exists
@verify_writable_gradebook_enabled
@course_author_access_required
def get(self, request, course_key):
def get(self, request, course_key): # lint-amnesty, pylint: disable=too-many-statements
"""
Returns a gradebook entry/entries (i.e. both course and subsection-level grade data)
for all users enrolled in a course, or a single user enrolled in a course
@@ -906,7 +906,7 @@ class GradebookBulkUpdateView(GradeViewMixin, PaginatedAPIView):
return override
@staticmethod
def _log_update_result(
def _log_update_result( # lint-amnesty, pylint: disable=missing-function-docstring
request_user,
user_id, usage_id,
subsection_grade_model=None,
@@ -1031,7 +1031,7 @@ class SubsectionGradeView(GradeViewMixin, APIView):
try:
usage_key = UsageKey.from_string(subsection_id)
except InvalidKeyError:
raise self.api_error(
raise self.api_error( # lint-amnesty, pylint: disable=raise-missing-from
status_code=status.HTTP_404_NOT_FOUND,
developer_message='Invalid UsageKey',
error_code='invalid_usage_key'
@@ -1047,7 +1047,7 @@ class SubsectionGradeView(GradeViewMixin, APIView):
try:
user_id = int(request.GET.get('user_id'))
except ValueError:
raise self.api_error(
raise self.api_error( # lint-amnesty, pylint: disable=raise-missing-from
status_code=status.HTTP_404_NOT_FOUND,
developer_message='Invalid UserID',
error_code='invalid_user_id'

View File

@@ -77,7 +77,7 @@ class GradeViewTestMixin(SharedModuleStoreTestCase):
created=self.date,
)
def _create_user_program_enrollments(self, *users, **kwargs):
def _create_user_program_enrollments(self, *users, **kwargs): # lint-amnesty, pylint: disable=missing-function-docstring
# supply mode for enrollment. Use 'masters' to create a masters track enrollment
for index, user in enumerate(users):
course_enrollment = CourseEnrollmentFactory(
@@ -99,7 +99,7 @@ class GradeViewTestMixin(SharedModuleStoreTestCase):
)
def setUp(self):
super(GradeViewTestMixin, self).setUp()
super(GradeViewTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.password = 'test'
self.global_staff = GlobalStaffFactory.create()
self.student = UserFactory(password=self.password, username='student', email='student@example.com')

View File

@@ -1,4 +1,4 @@
"""
""" # lint-amnesty, pylint: disable=cyclic-import
Tests for the course grading API view
"""
@@ -18,7 +18,7 @@ from rest_framework.test import APITestCase
from six import text_type
from common.djangoapps.course_modes.models import CourseMode
from edx_toggles.toggles.testutils import override_waffle_flag
from edx_toggles.toggles.testutils import override_waffle_flag # lint-amnesty, pylint: disable=wrong-import-order
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
from lms.djangoapps.courseware.tests.factories import InstructorFactory, StaffFactory
from lms.djangoapps.grades.config.waffle import WRITABLE_GRADEBOOK, waffle_flags
@@ -397,7 +397,7 @@ class GradebookViewTest(GradebookViewTestBase):
"""
Helper function to create the course gradebook API read url.
"""
base_url = super(GradebookViewTest, self).get_url(course_key)
base_url = super(GradebookViewTest, self).get_url(course_key) # lint-amnesty, pylint: disable=super-with-arguments
if username:
return "{0}?username={1}".format(base_url, username)
if user_contains:

View File

@@ -27,7 +27,7 @@ class GradingPolicyTestMixin(object):
view_name = None
def setUp(self):
super(GradingPolicyTestMixin, self).setUp()
super(GradingPolicyTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.create_user_and_access_token()
def create_user_and_access_token(self):
@@ -36,7 +36,7 @@ class GradingPolicyTestMixin(object):
self.access_token = AccessTokenFactory.create(user=self.user, application=self.oauth_client).token
@classmethod
def create_course_data(cls):
def create_course_data(cls): # lint-amnesty, pylint: disable=missing-function-docstring
cls.invalid_course_id = 'foo/bar/baz'
cls.course = CourseFactory.create(display_name='An Introduction to API Testing', raw_grader=cls.raw_grader)
cls.course_id = six.text_type(cls.course.id)
@@ -188,7 +188,7 @@ class CourseGradingPolicyTests(GradingPolicyTestMixin, SharedModuleStoreTestCase
"""
The view should return grading policy for a course.
"""
response = super(CourseGradingPolicyTests, self).test_get()
response = super(CourseGradingPolicyTests, self).test_get() # lint-amnesty, pylint: disable=super-with-arguments
expected = [
{
@@ -240,7 +240,7 @@ class CourseGradingPolicyMissingFieldsTests(GradingPolicyTestMixin, SharedModule
"""
The view should return grading policy for a course.
"""
response = super(CourseGradingPolicyMissingFieldsTests, self).test_get()
response = super(CourseGradingPolicyMissingFieldsTests, self).test_get() # lint-amnesty, pylint: disable=super-with-arguments
expected = [
{

View File

@@ -45,7 +45,7 @@ class CourseEnrollmentPagination(CursorPagination):
Return a response given serialized page data, optional status_code (defaults to 200),
and kwargs. Each key-value pair of kwargs is added to the response data.
"""
resp = super(CourseEnrollmentPagination, self).get_paginated_response(data)
resp = super(CourseEnrollmentPagination, self).get_paginated_response(data) # lint-amnesty, pylint: disable=super-with-arguments
for (key, value) in kwargs.items():
resp.data[key] = value
@@ -103,13 +103,13 @@ class GradeViewMixin(DeveloperErrorViewMixin):
try:
yield self._get_single_user(request, course_key)
except USER_MODEL.DoesNotExist:
raise self.api_error(
raise self.api_error( # lint-amnesty, pylint: disable=raise-missing-from
status_code=status.HTTP_404_NOT_FOUND,
developer_message='The user matching the requested username does not exist.',
error_code='user_does_not_exist'
)
except CourseEnrollment.DoesNotExist:
raise self.api_error(
raise self.api_error( # lint-amnesty, pylint: disable=raise-missing-from
status_code=status.HTTP_404_NOT_FOUND,
developer_message='The user matching the requested username is not enrolled in this course',
error_code='user_not_enrolled'
@@ -181,6 +181,6 @@ class GradeViewMixin(DeveloperErrorViewMixin):
"""
Ensures that the user is authenticated (e.g. not an AnonymousUser).
"""
super(GradeViewMixin, self).perform_authentication(request)
super(GradeViewMixin, self).perform_authentication(request) # lint-amnesty, pylint: disable=super-with-arguments
if request.user.is_anonymous:
raise AuthenticationFailed

View File

@@ -182,7 +182,7 @@ class CourseGradingPolicy(GradeViewMixin, ListAPIView):
try:
course_key = get_course_key(request, course_id)
except InvalidKeyError:
raise self.api_error(
raise self.api_error( # lint-amnesty, pylint: disable=raise-missing-from
status_code=status.HTTP_400_BAD_REQUEST,
developer_message='The provided course key cannot be parsed.',
error_code='invalid_course_key'