From 44576ce3f6afafa320613fdba70071cbc60d211e Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Mon, 1 Feb 2021 19:27:15 +0500 Subject: [PATCH 01/19] BOM-2282 Apply pylint-amnesty. --- lms/djangoapps/instructor_analytics/basic.py | 6 +-- .../instructor_analytics/distributions.py | 6 +-- .../instructor_analytics/tests/test_basic.py | 22 ++++----- .../instructor_analytics/tests/test_csvs.py | 2 +- .../tests/test_distributions.py | 4 +- lms/djangoapps/instructor_task/__init__.py | 2 +- lms/djangoapps/instructor_task/admin.py | 4 +- lms/djangoapps/instructor_task/api.py | 2 +- lms/djangoapps/instructor_task/api_helper.py | 6 +-- lms/djangoapps/instructor_task/exceptions.py | 4 +- .../management/commands/fail_old_tasks.py | 2 +- .../commands/tests/test_fail_old_tasks.py | 2 +- lms/djangoapps/instructor_task/models.py | 2 +- lms/djangoapps/instructor_task/subtasks.py | 20 ++++---- lms/djangoapps/instructor_task/tasks.py | 2 +- lms/djangoapps/instructor_task/tasks_base.py | 4 +- .../instructor_task/tasks_helper/certs.py | 2 +- .../tasks_helper/enrollments.py | 18 +++---- .../instructor_task/tasks_helper/grades.py | 24 +++++----- .../instructor_task/tasks_helper/misc.py | 20 ++++---- .../tasks_helper/module_state.py | 4 +- .../instructor_task/tests/factories.py | 2 +- .../instructor_task/tests/test_api.py | 6 +-- .../instructor_task/tests/test_base.py | 8 ++-- .../instructor_task/tests/test_integration.py | 16 +++---- .../instructor_task/tests/test_models.py | 6 +-- .../instructor_task/tests/test_subtasks.py | 4 +- .../instructor_task/tests/test_tasks.py | 18 +++---- .../tests/test_tasks_helper.py | 48 +++++++++---------- lms/djangoapps/instructor_task/views.py | 24 +++++----- lms/djangoapps/learner_dashboard/programs.py | 4 +- .../learner_dashboard/tests/test_programs.py | 14 +++--- 32 files changed, 154 insertions(+), 154 deletions(-) diff --git a/lms/djangoapps/instructor_analytics/basic.py b/lms/djangoapps/instructor_analytics/basic.py index e600d72208..45539a7262 100644 --- a/lms/djangoapps/instructor_analytics/basic.py +++ b/lms/djangoapps/instructor_analytics/basic.py @@ -11,10 +11,10 @@ import logging import six from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import ObjectDoesNotExist from django.core.serializers.json import DjangoJSONEncoder -from django.db.models import Count, Q +from django.db.models import Count, Q # lint-amnesty, pylint: disable=unused-import from django.urls import reverse from edx_proctoring.api import get_exam_violation_report from opaque_keys.edx.keys import CourseKey, UsageKey @@ -426,7 +426,7 @@ def course_registration_features(features, registration_codes, csv_type): site_name = configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME) registration_features = [x for x in COURSE_REGISTRATION_FEATURES if x in features] - course_registration_dict = dict((feature, getattr(registration_code, feature)) for feature in registration_features) + course_registration_dict = dict((feature, getattr(registration_code, feature)) for feature in registration_features) # lint-amnesty, pylint: disable=line-too-long course_registration_dict['company_name'] = None if registration_code.invoice_item: course_registration_dict['company_name'] = registration_code.invoice_item.invoice.company_name diff --git a/lms/djangoapps/instructor_analytics/distributions.py b/lms/djangoapps/instructor_analytics/distributions.py index 5d7c633e06..bfe96cfdee 100644 --- a/lms/djangoapps/instructor_analytics/distributions.py +++ b/lms/djangoapps/instructor_analytics/distributions.py @@ -52,7 +52,7 @@ class ProfileDistribution(object): class ValidationError(ValueError): """ Error thrown if validation fails. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def __init__(self, feature): self.feature = feature @@ -112,7 +112,7 @@ def profile_distribution(course_id, feature): # short name and display name (full) of the choices. choices = [(short, full) - for (short, full) in raw_choices] + [('no_data', 'No Data')] + for (short, full) in raw_choices] + [('no_data', 'No Data')] # lint-amnesty, pylint: disable=unnecessary-comprehension def get_filter(feature, value): """ Get the orm filter parameters for a feature. """ @@ -130,7 +130,7 @@ def profile_distribution(course_id, feature): ).count() distribution = {} - for (short, full) in choices: + for (short, full) in choices: # lint-amnesty, pylint: disable=unused-variable # handle no data case if short == 'no_data': distribution['no_data'] = 0 diff --git a/lms/djangoapps/instructor_analytics/tests/test_basic.py b/lms/djangoapps/instructor_analytics/tests/test_basic.py index 363ff20d0e..99294bd972 100644 --- a/lms/djangoapps/instructor_analytics/tests/test_basic.py +++ b/lms/djangoapps/instructor_analytics/tests/test_basic.py @@ -5,23 +5,23 @@ Tests for instructor.basic import ddt -import datetime -import json +import datetime # lint-amnesty, pylint: disable=unused-import, wrong-import-order +import json # lint-amnesty, pylint: disable=wrong-import-order -import pytz -from django.db.models import Q -from django.urls import reverse +import pytz # lint-amnesty, pylint: disable=unused-import +from django.db.models import Q # lint-amnesty, pylint: disable=unused-import +from django.urls import reverse # lint-amnesty, pylint: disable=unused-import from edx_proctoring.api import create_exam from edx_proctoring.models import ProctoredExamStudentAttempt from mock import MagicMock, Mock, patch from opaque_keys.edx.locator import UsageKey -from six import text_type +from six import text_type # lint-amnesty, pylint: disable=unused-import from six.moves import range, zip -from common.djangoapps.course_modes.models import CourseMode -from common.djangoapps.course_modes.tests.factories import CourseModeFactory +from common.djangoapps.course_modes.models import CourseMode # lint-amnesty, pylint: disable=unused-import +from common.djangoapps.course_modes.tests.factories import CourseModeFactory # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.courseware.tests.factories import InstructorFactory -from lms.djangoapps.instructor_analytics.basic import ( +from lms.djangoapps.instructor_analytics.basic import ( # lint-amnesty, pylint: disable=unused-import AVAILABLE_FEATURES, PROFILE_FEATURES, STUDENT_FEATURES, @@ -36,7 +36,7 @@ from lms.djangoapps.instructor_analytics.basic import ( ) from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory from common.djangoapps.student.models import CourseEnrollment, CourseEnrollmentAllowed -from common.djangoapps.student.roles import CourseSalesAdminRole +from common.djangoapps.student.roles import CourseSalesAdminRole # lint-amnesty, pylint: disable=unused-import from common.djangoapps.student.tests.factories import UserFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory @@ -47,7 +47,7 @@ class TestAnalyticsBasic(ModuleStoreTestCase): """ Test basic analytics functions. """ def setUp(self): - super(TestAnalyticsBasic, self).setUp() + super(TestAnalyticsBasic, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_key = self.store.make_course_key('robot', 'course', 'id') self.users = tuple(UserFactory() for _ in range(30)) self.ces = tuple(CourseEnrollment.enroll(user, self.course_key) diff --git a/lms/djangoapps/instructor_analytics/tests/test_csvs.py b/lms/djangoapps/instructor_analytics/tests/test_csvs.py index f8f7d5c1cf..58075aaa5c 100644 --- a/lms/djangoapps/instructor_analytics/tests/test_csvs.py +++ b/lms/djangoapps/instructor_analytics/tests/test_csvs.py @@ -105,7 +105,7 @@ class TestAnalyticsFormatInstances(TestCase): return 'dval' def setUp(self): - super(TestAnalyticsFormatInstances, self).setUp() + super(TestAnalyticsFormatInstances, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.instances = [self.TestDataClass() for _ in range(5)] def test_format_instances_response(self): diff --git a/lms/djangoapps/instructor_analytics/tests/test_distributions.py b/lms/djangoapps/instructor_analytics/tests/test_distributions.py index dc96edc541..fb7e941bf3 100644 --- a/lms/djangoapps/instructor_analytics/tests/test_distributions.py +++ b/lms/djangoapps/instructor_analytics/tests/test_distributions.py @@ -15,7 +15,7 @@ class TestAnalyticsDistributions(TestCase): '''Test analytics distribution gathering.''' def setUp(self): - super(TestAnalyticsDistributions, self).setUp() + super(TestAnalyticsDistributions, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_id = CourseLocator('robot', 'course', 'id') self.users = [UserFactory( @@ -78,7 +78,7 @@ class TestAnalyticsDistributionsNoData(TestCase): '''Test analytics distribution gathering.''' def setUp(self): - super(TestAnalyticsDistributionsNoData, self).setUp() + super(TestAnalyticsDistributionsNoData, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_id = CourseLocator('robot', 'course', 'id') self.users = [UserFactory( diff --git a/lms/djangoapps/instructor_task/__init__.py b/lms/djangoapps/instructor_task/__init__.py index 6f2eba3c8b..d29347c62a 100644 --- a/lms/djangoapps/instructor_task/__init__.py +++ b/lms/djangoapps/instructor_task/__init__.py @@ -1,2 +1,2 @@ -# pylint: disable=missing-module-docstring + # lint-amnesty, pylint: disable=django-not-configured, missing-module-docstring default_app_config = 'lms.djangoapps.instructor_task.apps.InstructorTaskConfig' diff --git a/lms/djangoapps/instructor_task/admin.py b/lms/djangoapps/instructor_task/admin.py index a7d63806e7..6833fae919 100644 --- a/lms/djangoapps/instructor_task/admin.py +++ b/lms/djangoapps/instructor_task/admin.py @@ -12,7 +12,7 @@ from .config.models import GradeReportSetting from .models import InstructorTask -def mark_tasks_as_failed(modeladmin, request, queryset): +def mark_tasks_as_failed(modeladmin, request, queryset): # lint-amnesty, pylint: disable=unused-argument queryset.update( task_state='FAILURE', task_output='{}', @@ -22,7 +22,7 @@ def mark_tasks_as_failed(modeladmin, request, queryset): mark_tasks_as_failed.short_description = "Mark Tasks as Failed" -class InstructorTaskAdmin(admin.ModelAdmin): +class InstructorTaskAdmin(admin.ModelAdmin): # lint-amnesty, pylint: disable=missing-class-docstring actions = [mark_tasks_as_failed] list_display = [ 'task_id', diff --git a/lms/djangoapps/instructor_task/api.py b/lms/djangoapps/instructor_task/api.py index d5ca3b7b26..003bdf727c 100644 --- a/lms/djangoapps/instructor_task/api.py +++ b/lms/djangoapps/instructor_task/api.py @@ -51,7 +51,7 @@ class SpecificStudentIdMissingError(Exception): """ Exception indicating that a student id was not provided when generating a certificate for a specific student. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def get_running_instructor_tasks(course_id): diff --git a/lms/djangoapps/instructor_task/api_helper.py b/lms/djangoapps/instructor_task/api_helper.py index 16c7dd00c9..bfa9b720d6 100644 --- a/lms/djangoapps/instructor_task/api_helper.py +++ b/lms/djangoapps/instructor_task/api_helper.py @@ -35,7 +35,7 @@ class AlreadyRunningError(Exception): if not message: message = self.message - super(AlreadyRunningError, self).__init__(message) + super(AlreadyRunningError, self).__init__(message) # lint-amnesty, pylint: disable=super-with-arguments class QueueConnectionError(Exception): @@ -47,7 +47,7 @@ class QueueConnectionError(Exception): def __init__(self, message=None): if not message: message = self.message - super(QueueConnectionError, self).__init__(message) + super(QueueConnectionError, self).__init__(message) # lint-amnesty, pylint: disable=super-with-arguments def _task_is_running(course_id, task_type, task_key): @@ -449,7 +449,7 @@ def submit_task(request, task_type, task_class, course_key, task_input, task_key try: task_class.apply_async(task_args, task_id=task_id) - except Exception as error: + except Exception as error: # lint-amnesty, pylint: disable=broad-except _handle_instructor_task_failure(instructor_task, error) return instructor_task diff --git a/lms/djangoapps/instructor_task/exceptions.py b/lms/djangoapps/instructor_task/exceptions.py index d2e6ad4b57..7d6bed2ee4 100644 --- a/lms/djangoapps/instructor_task/exceptions.py +++ b/lms/djangoapps/instructor_task/exceptions.py @@ -10,9 +10,9 @@ class UpdateProblemModuleStateError(Exception): Used when the current module cannot be processed and no more modules should be attempted. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class DuplicateTaskException(Exception): """Exception indicating that a task already exists or has already completed.""" - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass diff --git a/lms/djangoapps/instructor_task/management/commands/fail_old_tasks.py b/lms/djangoapps/instructor_task/management/commands/fail_old_tasks.py index 476871aea3..a1b5f65ab1 100644 --- a/lms/djangoapps/instructor_task/management/commands/fail_old_tasks.py +++ b/lms/djangoapps/instructor_task/management/commands/fail_old_tasks.py @@ -96,7 +96,7 @@ class Command(BaseCommand): for task in tasks: print( - "{task_state} task '{task_id}', of type '{task_type}', created on '{created}', will be marked as 'FAILURE'".format( + "{task_state} task '{task_id}', of type '{task_type}', created on '{created}', will be marked as 'FAILURE'".format( # lint-amnesty, pylint: disable=line-too-long task_state=task.task_state, task_id=task.task_id, task_type=task.task_type, diff --git a/lms/djangoapps/instructor_task/management/commands/tests/test_fail_old_tasks.py b/lms/djangoapps/instructor_task/management/commands/tests/test_fail_old_tasks.py index 9c1062cd4d..f2ffc88aa1 100644 --- a/lms/djangoapps/instructor_task/management/commands/tests/test_fail_old_tasks.py +++ b/lms/djangoapps/instructor_task/management/commands/tests/test_fail_old_tasks.py @@ -23,7 +23,7 @@ class TestFailOldQueueingTasksCommand(InstructorTaskTestCase): """ def setUp(self): - super(TestFailOldQueueingTasksCommand, self).setUp() + super(TestFailOldQueueingTasksCommand, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments type_1_queueing = InstructorTaskFactory.create( task_state=QUEUING, diff --git a/lms/djangoapps/instructor_task/models.py b/lms/djangoapps/instructor_task/models.py index 95a8d05d0a..12a4b6a815 100644 --- a/lms/djangoapps/instructor_task/models.py +++ b/lms/djangoapps/instructor_task/models.py @@ -25,7 +25,7 @@ from uuid import uuid4 import six from boto.exception import BotoServerError from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.files.base import ContentFile from django.db import models, transaction from django.utils.encoding import python_2_unicode_compatible diff --git a/lms/djangoapps/instructor_task/subtasks.py b/lms/djangoapps/instructor_task/subtasks.py index 26ab42fc74..cb93248b6e 100644 --- a/lms/djangoapps/instructor_task/subtasks.py +++ b/lms/djangoapps/instructor_task/subtasks.py @@ -49,7 +49,7 @@ def _get_number_of_subtasks(total_num_items, items_per_task): @contextmanager -def track_memory_usage(metric, course_id): +def track_memory_usage(metric, course_id): # lint-amnesty, pylint: disable=unused-argument """ Context manager to track how much memory (in bytes) a given process uses. Metrics will look like: 'course_email.subtask_generation.memory.rss' @@ -63,11 +63,11 @@ def track_memory_usage(metric, course_id): for memory_type, baseline_usage in zip(memory_types, baseline_usages): total_memory_info = process.memory_info() total_usage = getattr(total_memory_info, memory_type) - memory_used = total_usage - baseline_usage + memory_used = total_usage - baseline_usage # lint-amnesty, pylint: disable=unused-variable def _generate_items_for_subtask( - item_querysets, # pylint: disable=bad-continuation + item_querysets, # lint-amnesty, pylint: disable=bad-continuation, bad-option-value item_fields, total_num_items, items_per_task, @@ -119,7 +119,7 @@ def _generate_items_for_subtask( # more items than items_per_task allows. We expect this to be a small enough # number as to be negligible. if num_items_queued != total_num_items: - TASK_LOG.info(u"Number of items generated by chunking %s not equal to original total %s", num_items_queued, total_num_items) + TASK_LOG.info(u"Number of items generated by chunking %s not equal to original total %s", num_items_queued, total_num_items) # lint-amnesty, pylint: disable=line-too-long @python_2_unicode_compatible @@ -148,7 +148,7 @@ class SubtaskStatus(object): Also, we should count up "not attempted" separately from attempted/failed. """ - def __init__(self, task_id, attempted=None, succeeded=0, failed=0, skipped=0, retried_nomax=0, retried_withmax=0, state=None): + def __init__(self, task_id, attempted=None, succeeded=0, failed=0, skipped=0, retried_nomax=0, retried_withmax=0, state=None): # lint-amnesty, pylint: disable=line-too-long """Construct a SubtaskStatus object.""" self.task_id = task_id if attempted is not None: @@ -273,7 +273,7 @@ def initialize_subtask_info(entry, action_name, total_num, subtask_id_list): return task_progress -# pylint: disable=bad-continuation + # lint-amnesty, pylint: disable=bad-continuation, bad-option-value def queue_subtasks_for_query( entry, action_name, @@ -421,7 +421,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status): subtask_dict = json.loads(entry.subtasks) subtask_status_info = subtask_dict['status'] if current_task_id not in subtask_status_info: - format_str = u"Unexpected task_id '{}': unable to find status for subtask of instructor task '{}': rejecting task {}" + format_str = u"Unexpected task_id '{}': unable to find status for subtask of instructor task '{}': rejecting task {}" # lint-amnesty, pylint: disable=line-too-long msg = format_str.format(current_task_id, entry, new_subtask_status) TASK_LOG.warning(msg) raise DuplicateTaskException(msg) @@ -431,7 +431,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status): subtask_status = SubtaskStatus.from_dict(subtask_status_info[current_task_id]) subtask_state = subtask_status.state if subtask_state in READY_STATES: - format_str = u"Unexpected task_id '{}': already completed - status {} for subtask of instructor task '{}': rejecting task {}" + format_str = u"Unexpected task_id '{}': already completed - status {} for subtask of instructor task '{}': rejecting task {}" # lint-amnesty, pylint: disable=line-too-long msg = format_str.format(current_task_id, subtask_status, entry, new_subtask_status) TASK_LOG.warning(msg) raise DuplicateTaskException(msg) @@ -444,7 +444,7 @@ def check_subtask_is_valid(entry_id, current_task_id, new_subtask_status): new_retry_count = new_subtask_status.get_retry_count() current_retry_count = subtask_status.get_retry_count() if new_retry_count < current_retry_count: - format_str = u"Unexpected task_id '{}': already retried - status {} for subtask of instructor task '{}': rejecting task {}" + format_str = u"Unexpected task_id '{}': already retried - status {} for subtask of instructor task '{}': rejecting task {}" # lint-amnesty, pylint: disable=line-too-long msg = format_str.format(current_task_id, subtask_status, entry, new_subtask_status) TASK_LOG.warning(msg) raise DuplicateTaskException(msg) @@ -481,7 +481,7 @@ def update_subtask_status(entry_id, current_task_id, new_subtask_status, retry_c current_task_id, entry_id, new_subtask_status, retry_count) update_subtask_status(entry_id, current_task_id, new_subtask_status, retry_count) else: - TASK_LOG.info(u"Failed to update status after %d retries for subtask %s of instructor task %d with status %s", + TASK_LOG.info(u"Failed to update status after %d retries for subtask %s of instructor task %d with status %s", # lint-amnesty, pylint: disable=line-too-long retry_count, current_task_id, entry_id, new_subtask_status) raise finally: diff --git a/lms/djangoapps/instructor_task/tasks.py b/lms/djangoapps/instructor_task/tasks.py index c069887aa0..b7514ea484 100644 --- a/lms/djangoapps/instructor_task/tasks.py +++ b/lms/djangoapps/instructor_task/tasks.py @@ -24,7 +24,7 @@ import logging from functools import partial from celery import shared_task -from django.conf import settings +from django.conf import settings # lint-amnesty, pylint: disable=unused-import from django.utils.translation import ugettext_noop from edx_django_utils.monitoring import set_code_owner_attribute diff --git a/lms/djangoapps/instructor_task/tasks_base.py b/lms/djangoapps/instructor_task/tasks_base.py index dd2f068713..bd2e07581c 100644 --- a/lms/djangoapps/instructor_task/tasks_base.py +++ b/lms/djangoapps/instructor_task/tasks_base.py @@ -14,7 +14,7 @@ from lms.djangoapps.instructor_task.models import InstructorTask TASK_LOG = logging.getLogger('edx.celery.task') -class BaseInstructorTask(Task): +class BaseInstructorTask(Task): # lint-amnesty, pylint: disable=abstract-method """ Base task class for use with InstructorTask models. @@ -30,7 +30,7 @@ class BaseInstructorTask(Task): """ abstract = True - def on_success(self, task_progress, task_id, args, kwargs): + def on_success(self, task_progress, task_id, args, kwargs): # lint-amnesty, pylint: disable=arguments-differ """ Update InstructorTask object corresponding to this task with info about success. diff --git a/lms/djangoapps/instructor_task/tasks_helper/certs.py b/lms/djangoapps/instructor_task/tasks_helper/certs.py index 04250be8f9..77ed261c44 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/certs.py +++ b/lms/djangoapps/instructor_task/tasks_helper/certs.py @@ -5,7 +5,7 @@ Instructor tasks related to certificates. from time import time -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.db.models import Q from lms.djangoapps.certificates.api import generate_user_certificates diff --git a/lms/djangoapps/instructor_task/tasks_helper/enrollments.py b/lms/djangoapps/instructor_task/tasks_helper/enrollments.py index 3b2b8c9588..fdc75c3060 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/enrollments.py +++ b/lms/djangoapps/instructor_task/tasks_helper/enrollments.py @@ -7,21 +7,21 @@ import logging from datetime import datetime from time import time -from django.conf import settings -from django.utils.translation import ugettext as _ +from django.conf import settings # lint-amnesty, pylint: disable=unused-import +from django.utils.translation import ugettext as _ # lint-amnesty, pylint: disable=unused-import from pytz import UTC -from six import StringIO +from six import StringIO # lint-amnesty, pylint: disable=unused-import -from common.djangoapps.edxmako.shortcuts import render_to_string -from lms.djangoapps.courseware.courses import get_course_by_id +from common.djangoapps.edxmako.shortcuts import render_to_string # lint-amnesty, pylint: disable=unused-import +from lms.djangoapps.courseware.courses import get_course_by_id # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.instructor_analytics.basic import enrolled_students_features, list_may_enroll from lms.djangoapps.instructor_analytics.csvs import format_dictlist -from lms.djangoapps.instructor_task.models import ReportStore -from common.djangoapps.student.models import CourseAccessRole, CourseEnrollment -from common.djangoapps.util.file import course_filename_prefix_generator +from lms.djangoapps.instructor_task.models import ReportStore # lint-amnesty, pylint: disable=unused-import +from common.djangoapps.student.models import CourseAccessRole, CourseEnrollment # lint-amnesty, pylint: disable=unused-import +from common.djangoapps.util.file import course_filename_prefix_generator # lint-amnesty, pylint: disable=unused-import from .runner import TaskProgress -from .utils import tracker_emit, upload_csv_to_report_store +from .utils import tracker_emit, upload_csv_to_report_store # lint-amnesty, pylint: disable=unused-import TASK_LOG = logging.getLogger('edx.celery.task') FILTERED_OUT_ROLES = ['staff', 'instructor', 'finance_admin', 'sales_admin'] diff --git a/lms/djangoapps/instructor_task/tasks_helper/grades.py b/lms/djangoapps/instructor_task/tasks_helper/grades.py index 1ac1ef8373..1095609c03 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/grades.py +++ b/lms/djangoapps/instructor_task/tasks_helper/grades.py @@ -11,13 +11,13 @@ from time import time import re import six from lms.djangoapps.course_blocks.api import get_course_blocks -from django.conf import settings -from django.contrib.auth import get_user_model -from lazy import lazy -from opaque_keys.edx.keys import UsageKey -from pytz import UTC -from six import text_type -from six.moves import zip, zip_longest +from django.conf import settings # lint-amnesty, pylint: disable=wrong-import-order +from django.contrib.auth import get_user_model # lint-amnesty, pylint: disable=wrong-import-order +from lazy import lazy # lint-amnesty, pylint: disable=wrong-import-order +from opaque_keys.edx.keys import UsageKey # lint-amnesty, pylint: disable=wrong-import-order +from pytz import UTC # lint-amnesty, pylint: disable=wrong-import-order +from six import text_type # lint-amnesty, pylint: disable=wrong-import-order +from six.moves import zip, zip_longest # lint-amnesty, pylint: disable=wrong-import-order from common.djangoapps.course_modes.models import CourseMode from lms.djangoapps.certificates.models import CertificateWhitelist, GeneratedCertificate, certificate_info_for_user @@ -371,7 +371,7 @@ class _CertificateBulkContext(object): } -class _TeamBulkContext(object): +class _TeamBulkContext(object): # lint-amnesty, pylint: disable=missing-class-docstring def __init__(self, context, users): self.enabled = context.teams_enabled if self.enabled: @@ -390,7 +390,7 @@ class _EnrollmentBulkContext(object): self.verified_users = set(IDVerificationService.get_verified_user_ids(users)) -class _CourseGradeBulkContext(object): +class _CourseGradeBulkContext(object): # lint-amnesty, pylint: disable=missing-class-docstring def __init__(self, context, users): self.certs = _CertificateBulkContext(context, users) self.teams = _TeamBulkContext(context, users) @@ -415,7 +415,7 @@ class CourseGradeReport(object): """ with modulestore().bulk_operations(course_id): context = _CourseGradeReportContext(_xmodule_instance_args, _entry_id, course_id, _task_input, action_name) - return CourseGradeReport()._generate(context) + return CourseGradeReport()._generate(context) # lint-amnesty, pylint: disable=protected-access def _generate(self, context): """ @@ -604,7 +604,7 @@ class CourseGradeReport(object): subsection_grades.append(subsection_grade) return subsection_grades, grade_results - def _user_assignment_average(self, course_grade, subsection_grades, assignment_info): + def _user_assignment_average(self, course_grade, subsection_grades, assignment_info): # lint-amnesty, pylint: disable=missing-function-docstring if assignment_info['separate_subsection_avg_headers']: if assignment_info['grader']: if course_grade.attempted: @@ -902,7 +902,7 @@ class ProblemResponses(object): student_data_keys = OrderedDict() with store.bulk_operations(course_key): - for usage_key in usage_keys: + for usage_key in usage_keys: # lint-amnesty, pylint: disable=too-many-nested-blocks if max_count is not None and max_count <= 0: break course_blocks = get_course_blocks(user, usage_key) diff --git a/lms/djangoapps/instructor_task/tasks_helper/misc.py b/lms/djangoapps/instructor_task/tasks_helper/misc.py index b8e0fa5592..96680c2a23 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/misc.py +++ b/lms/djangoapps/instructor_task/tasks_helper/misc.py @@ -9,16 +9,16 @@ import logging from collections import OrderedDict from contextlib import contextmanager from datetime import datetime -from io import StringIO +from io import StringIO # lint-amnesty, pylint: disable=unused-import from tempfile import TemporaryFile from time import time -from zipfile import ZipFile +from zipfile import ZipFile # lint-amnesty, pylint: disable=unused-import import csv -import os +import os # lint-amnesty, pylint: disable=unused-import import unicodecsv import six -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import ValidationError from django.core.files.storage import DefaultStorage from openassessment.data import OraAggregateData, OraDownloadData @@ -172,7 +172,7 @@ def _get_csv_file_content(csv_file): return UniversalNewlineIterator(csv_content) -def cohort_students_and_upload(_xmodule_instance_args, _entry_id, course_id, task_input, action_name): +def cohort_students_and_upload(_xmodule_instance_args, _entry_id, course_id, task_input, action_name): # lint-amnesty, pylint: disable=too-many-statements """ Within a given course, cohort students in bulk, then upload the results using a `ReportStore`. @@ -240,7 +240,7 @@ def cohort_students_and_upload(_xmodule_instance_args, _entry_id, course_id, tas try: # If add_user_to_cohort successfully adds a user, a user object is returned. # If a user is preassigned to a cohort, no user object is returned (we already have the email address). - (user, previous_cohort, preassigned) = add_user_to_cohort(cohorts_status[cohort_name]['cohort'], username_or_email) + (user, previous_cohort, preassigned) = add_user_to_cohort(cohorts_status[cohort_name]['cohort'], username_or_email) # lint-amnesty, pylint: disable=line-too-long, unused-variable if preassigned: cohorts_status[cohort_name]['Preassigned Learners'].add(username_or_email) task_progress.preassigned += 1 @@ -268,10 +268,10 @@ def cohort_students_and_upload(_xmodule_instance_args, _entry_id, course_id, tas task_progress.update_task_state(extra_meta=current_step) # Filter the output of `add_users_to_cohorts` in order to upload the result. - output_header = ['Cohort Name', 'Exists', 'Learners Added', 'Learners Not Found', 'Invalid Email Addresses', 'Preassigned Learners'] + output_header = ['Cohort Name', 'Exists', 'Learners Added', 'Learners Not Found', 'Invalid Email Addresses', 'Preassigned Learners'] # lint-amnesty, pylint: disable=line-too-long output_rows = [ [ - ','.join(status_dict.get(column_name, '')) if (column_name == 'Learners Not Found' + ','.join(status_dict.get(column_name, '')) if (column_name == 'Learners Not Found' # lint-amnesty, pylint: disable=consider-using-in or column_name == 'Invalid Email Addresses' or column_name == 'Preassigned Learners') else status_dict[column_name] @@ -322,7 +322,7 @@ def upload_ora2_data( try: header, datarows = OraAggregateData.collect_ora2_data(course_id) - rows = [header] + [row for row in datarows] + rows = [header] + [row for row in datarows] # lint-amnesty, pylint: disable=unnecessary-comprehension # Update progress to failed regardless of error type except Exception: # pylint: disable=broad-except TASK_LOG.exception('Failed to get ORA data.') @@ -444,7 +444,7 @@ def upload_ora2_submission_files( 'Failed to upload zip file to storage.', 'Error while uploading zip file to storage', ): - zip_filename = upload_zip_to_report_store(zip_file, 'submission_files', course_id, start_date), + zip_filename = upload_zip_to_report_store(zip_file, 'submission_files', course_id, start_date), # lint-amnesty, pylint: disable=trailing-comma-tuple if not zip_filename: return UPDATE_STATUS_FAILED diff --git a/lms/djangoapps/instructor_task/tasks_helper/module_state.py b/lms/djangoapps/instructor_task/tasks_helper/module_state.py index 65a6998f96..5b167d5132 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/module_state.py +++ b/lms/djangoapps/instructor_task/tasks_helper/module_state.py @@ -241,7 +241,7 @@ def override_score_module_state(xmodule_instance_args, module_descriptor, studen raise UpdateProblemModuleStateError(msg) weighted_override_score = float(task_input['score']) - if not (0 <= weighted_override_score <= instance.max_score()): + if not (0 <= weighted_override_score <= instance.max_score()): # lint-amnesty, pylint: disable=superfluous-parens msg = "Score must be between 0 and the maximum points available for the problem." raise UpdateProblemModuleStateError(msg) @@ -252,7 +252,7 @@ def override_score_module_state(xmodule_instance_args, module_descriptor, studen set_event_transaction_type(grades_events.GRADES_OVERRIDE_EVENT_TYPE) problem_weight = instance.weight if instance.weight is not None else 1 - if problem_weight == 0: + if problem_weight == 0: # lint-amnesty, pylint: disable=no-else-raise msg = "Scores cannot be overridden for a problem that has a weight of zero." raise UpdateProblemModuleStateError(msg) else: diff --git a/lms/djangoapps/instructor_task/tests/factories.py b/lms/djangoapps/instructor_task/tests/factories.py index 47dbefdf59..423ec7cec0 100644 --- a/lms/djangoapps/instructor_task/tests/factories.py +++ b/lms/djangoapps/instructor_task/tests/factories.py @@ -14,7 +14,7 @@ from lms.djangoapps.instructor_task.models import InstructorTask from common.djangoapps.student.tests.factories import UserFactory as StudentUserFactory -class InstructorTaskFactory(DjangoModelFactory): +class InstructorTaskFactory(DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring class Meta(object): model = InstructorTask diff --git a/lms/djangoapps/instructor_task/tests/test_api.py b/lms/djangoapps/instructor_task/tests/test_api.py index c046e56233..2fffc7aa7e 100644 --- a/lms/djangoapps/instructor_task/tests/test_api.py +++ b/lms/djangoapps/instructor_task/tests/test_api.py @@ -95,7 +95,7 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase): """Tests API methods that involve the submission of module-based background tasks.""" def setUp(self): - super(InstructorTaskModuleSubmitTest, self).setUp() + super(InstructorTaskModuleSubmitTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.initialize_course() self.student = UserFactory.create(username="student", email="student@edx.org") @@ -189,12 +189,12 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase): task_function(self.create_task_request(self.instructor), location, **params) -@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) +@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) # lint-amnesty, pylint: disable=line-too-long class InstructorTaskCourseSubmitTest(TestReportMixin, InstructorTaskCourseTestCase): """Tests API methods that involve the submission of course-based background tasks.""" def setUp(self): - super(InstructorTaskCourseSubmitTest, self).setUp() + super(InstructorTaskCourseSubmitTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.initialize_course() self.student = UserFactory.create(username="student", email="student@edx.org") diff --git a/lms/djangoapps/instructor_task/tests/test_base.py b/lms/djangoapps/instructor_task/tests/test_base.py index be41f14fea..b12a6ec577 100644 --- a/lms/djangoapps/instructor_task/tests/test_base.py +++ b/lms/djangoapps/instructor_task/tests/test_base.py @@ -14,7 +14,7 @@ from uuid import uuid4 import six import unicodecsv from celery.states import FAILURE, SUCCESS -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.urls import reverse from mock import Mock, patch from opaque_keys.edx.keys import CourseKey @@ -55,7 +55,7 @@ class InstructorTaskTestCase(CacheIsolationTestCase): Tests API and view methods that involve the reporting of status for background tasks. """ def setUp(self): - super(InstructorTaskTestCase, self).setUp() + super(InstructorTaskTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.student = UserFactory.create(username="student", email="student@edx.org") self.instructor = UserFactory.create(username="instructor", email="instructor@edx.org") @@ -314,7 +314,7 @@ class TestReportMixin(object): if os.path.exists(self.tmp_dir): shutil.rmtree(self.tmp_dir) - super(TestReportMixin, self).setUp() + super(TestReportMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Ensure that working with the temp directories in tests is thread safe # by creating a unique temporary directory for each testcase. @@ -356,7 +356,7 @@ class TestReportMixin(object): report_path = report_store.path_to(self.course.id, report_csv_filename) with report_store.storage.open(report_path) as csv_file: # Expand the dict reader generator so we don't lose it's content - csv_rows = [row for row in unicodecsv.DictReader(csv_file, encoding='utf-8-sig')] + csv_rows = [row for row in unicodecsv.DictReader(csv_file, encoding='utf-8-sig')] # lint-amnesty, pylint: disable=unnecessary-comprehension if ignore_other_columns: csv_rows = [ diff --git a/lms/djangoapps/instructor_task/tests/test_integration.py b/lms/djangoapps/instructor_task/tests/test_integration.py index 487246c9ee..a8583194f3 100644 --- a/lms/djangoapps/instructor_task/tests/test_integration.py +++ b/lms/djangoapps/instructor_task/tests/test_integration.py @@ -15,7 +15,7 @@ from collections import namedtuple import ddt import six from celery.states import FAILURE, SUCCESS -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.test.utils import override_settings from django.urls import reverse from mock import patch @@ -61,7 +61,7 @@ class TestIntegrationTask(InstructorTaskModuleTestCase): self.assertEqual(instructor_task.task_type, task_type) task_input = json.loads(instructor_task.task_input) self.assertNotIn('student', task_input) - self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name))) + self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name))) # lint-amnesty, pylint: disable=line-too-long status = json.loads(instructor_task.task_output) self.assertEqual(status['exception'], 'ZeroDivisionError') self.assertEqual(status['message'], expected_message) @@ -80,7 +80,7 @@ class TestRescoringTask(TestIntegrationTask): """ def setUp(self): - super(TestRescoringTask, self).setUp() + super(TestRescoringTask, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.initialize_course() self.create_instructor('instructor') @@ -305,7 +305,7 @@ class TestRescoringTask(TestIntegrationTask): self.assertEqual(instructor_task.task_type, 'rescore_problem') task_input = json.loads(instructor_task.task_input) self.assertNotIn('student', task_input) - self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name))) + self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name))) # lint-amnesty, pylint: disable=line-too-long status = json.loads(instructor_task.task_output) self.assertEqual(status['attempted'], 1) self.assertEqual(status['succeeded'], 0) @@ -370,7 +370,7 @@ class TestRescoringTask(TestIntegrationTask): InstructorTaskModuleTestCase.problem_location(problem_url_name) ) descriptor.data = problem_xml - with self.module_store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, descriptor.location.course_key): + with self.module_store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, descriptor.location.course_key): # lint-amnesty, pylint: disable=line-too-long self.module_store.update_item(descriptor, self.user.id) self.module_store.publish(descriptor.location, self.user.id) else: @@ -444,7 +444,7 @@ class TestResetAttemptsTask(TestIntegrationTask): userlist = ['u1', 'u2', 'u3', 'u4'] def setUp(self): - super(TestResetAttemptsTask, self).setUp() + super(TestResetAttemptsTask, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.initialize_course() self.create_instructor('instructor') for username in self.userlist: @@ -513,7 +513,7 @@ class TestDeleteProblemTask(TestIntegrationTask): userlist = ['u1', 'u2', 'u3', 'u4'] def setUp(self): - super(TestDeleteProblemTask, self).setUp() + super(TestDeleteProblemTask, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.initialize_course() self.create_instructor('instructor') @@ -598,7 +598,7 @@ class TestGradeReportConditionalContent(TestReportMixin, TestConditionalContent, Arguments: dicts: tuple of dicts """ - return dict([item for d in dicts for item in d.items()]) + return dict([item for d in dicts for item in d.items()]) # lint-amnesty, pylint: disable=consider-using-dict-comprehension def user_partition_group(user): """Return a dict having single key with value equals to students group in partition""" diff --git a/lms/djangoapps/instructor_task/tests/test_models.py b/lms/djangoapps/instructor_task/tests/test_models.py index 77ebf579b4..324484141e 100644 --- a/lms/djangoapps/instructor_task/tests/test_models.py +++ b/lms/djangoapps/instructor_task/tests/test_models.py @@ -41,21 +41,21 @@ class ReportStoreTestMixin(object): """ def setUp(self): - super(ReportStoreTestMixin, self).setUp() + super(ReportStoreTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_id = CourseLocator(org="testx", course="coursex", run="runx") def create_report_store(self): """ Subclasses should override this and return their report store. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def test_links_for_order(self): """ Test that ReportStore.links_for() returns file download links in reverse chronological order. """ - report_store = self.create_report_store() + report_store = self.create_report_store() # lint-amnesty, pylint: disable=assignment-from-no-return self.assertEqual(report_store.links_for(self.course_id), []) report_store.store(self.course_id, 'old_file', StringIO()) diff --git a/lms/djangoapps/instructor_task/tests/test_subtasks.py b/lms/djangoapps/instructor_task/tests/test_subtasks.py index fc6fd4ef24..ece5ed4429 100644 --- a/lms/djangoapps/instructor_task/tests/test_subtasks.py +++ b/lms/djangoapps/instructor_task/tests/test_subtasks.py @@ -18,10 +18,10 @@ class TestSubtasks(InstructorTaskCourseTestCase): """Tests for subtasks.""" def setUp(self): - super(TestSubtasks, self).setUp() + super(TestSubtasks, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.initialize_course() - def _enroll_students_in_course(self, course_id, num_students): + def _enroll_students_in_course(self, course_id, num_students): # lint-amnesty, pylint: disable=unused-argument """Create and enroll some students in the course.""" for _ in range(num_students): diff --git a/lms/djangoapps/instructor_task/tests/test_tasks.py b/lms/djangoapps/instructor_task/tests/test_tasks.py index 5fd342708a..cc810035a0 100644 --- a/lms/djangoapps/instructor_task/tests/test_tasks.py +++ b/lms/djangoapps/instructor_task/tests/test_tasks.py @@ -7,7 +7,7 @@ paths actually work. import json -from functools import partial +from functools import partial # lint-amnesty, pylint: disable=unused-import from uuid import uuid4 import ddt @@ -31,7 +31,7 @@ from lms.djangoapps.instructor_task.tasks import ( rescore_problem, reset_problem_attempts ) -from lms.djangoapps.instructor_task.tasks_helper.misc import upload_ora2_data +from lms.djangoapps.instructor_task.tasks_helper.misc import upload_ora2_data # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory from lms.djangoapps.instructor_task.tests.test_base import InstructorTaskModuleTestCase from xmodule.modulestore.exceptions import ItemNotFoundError @@ -43,7 +43,7 @@ class TestTaskFailure(Exception): """ An example exception to indicate failure of a mocked task. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class TestInstructorTasks(InstructorTaskModuleTestCase): @@ -52,7 +52,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase): """ def setUp(self): - super(TestInstructorTasks, self).setUp() + super(TestInstructorTasks, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.initialize_course() self.instructor = self.create_instructor('instructor') self.location = self.problem_location(PROBLEM_URL_NAME) @@ -94,7 +94,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase): def _run_task_with_mock_celery(self, task_class, entry_id, task_id, expected_failure_message=None): """Submit a task and mock how celery provides a current_task.""" - self.current_task = Mock() + self.current_task = Mock() # lint-amnesty, pylint: disable=attribute-defined-outside-init self.current_task.request = Mock() self.current_task.request.id = task_id self.current_task.update_state = Mock() @@ -335,7 +335,7 @@ class TestOverrideScoreInstructorTask(TestInstructorTasks): Tests score override for a problem in a course, for all students succeeds. """ mock_instance = MagicMock() - getattr(mock_instance, 'override_problem_score').return_value = None + getattr(mock_instance, 'override_problem_score').return_value = None # lint-amnesty, pylint: disable=literal-used-as-attribute num_students = 10 self._create_students_with_state(num_students) @@ -428,7 +428,7 @@ class TestRescoreInstructorTask(TestInstructorTasks): mock_instance = MagicMock() del mock_instance.rescore_problem del mock_instance.rescore - with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal') as mock_get_module: + with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal') as mock_get_module: # lint-amnesty, pylint: disable=line-too-long mock_get_module.return_value = mock_instance with self.assertRaises(UpdateProblemModuleStateError): self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id) @@ -451,7 +451,7 @@ class TestRescoreInstructorTask(TestInstructorTasks): num_students = 1 self._create_students_with_state(num_students, input_state) task_entry = self._create_input_entry() - with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal', return_value=None): + with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal', return_value=None): # lint-amnesty, pylint: disable=line-too-long self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id) self.assert_task_output( @@ -469,7 +469,7 @@ class TestRescoreInstructorTask(TestInstructorTasks): Tests rescores a problem in a course, for all students succeeds. """ mock_instance = MagicMock() - getattr(mock_instance, 'rescore').return_value = None + getattr(mock_instance, 'rescore').return_value = None # lint-amnesty, pylint: disable=literal-used-as-attribute mock_instance.has_submitted_answer.return_value = True del mock_instance.done # old CAPA code used to use this value so we delete it here to be sure diff --git a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py index 4607e0903b..41da827b42 100644 --- a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py +++ b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py @@ -15,14 +15,14 @@ import tempfile from collections import OrderedDict from contextlib import contextmanager, ExitStack from datetime import datetime, timedelta -from io import BytesIO -from zipfile import ZipFile +from io import BytesIO # lint-amnesty, pylint: disable=unused-import +from zipfile import ZipFile # lint-amnesty, pylint: disable=unused-import import ddt import unicodecsv from django.conf import settings from django.test.utils import override_settings -from django.urls import reverse +from django.urls import reverse # lint-amnesty, pylint: disable=unused-import from edx_django_utils.cache import RequestCache from freezegun import freeze_time from mock import ANY, MagicMock, Mock, patch @@ -30,16 +30,16 @@ from pytz import UTC from six import text_type from six.moves import range, zip from six.moves.urllib.parse import quote -from waffle.testutils import override_switch +from waffle.testutils import override_switch # lint-amnesty, pylint: disable=unused-import import openedx.core.djangoapps.user_api.course_tag.api as course_tag_api from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory from common.djangoapps.course_modes.models import CourseMode -from common.djangoapps.course_modes.tests.factories import CourseModeFactory +from common.djangoapps.course_modes.tests.factories import CourseModeFactory # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.courseware.models import StudentModule from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate from lms.djangoapps.certificates.tests.factories import CertificateWhitelistFactory, GeneratedCertificateFactory -from lms.djangoapps.courseware.tests.factories import InstructorFactory +from lms.djangoapps.courseware.tests.factories import InstructorFactory # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.grades.course_data import CourseData from lms.djangoapps.grades.models import PersistentCourseGrade, PersistentSubsectionGradeOverride from lms.djangoapps.grades.subsection_grade import CreateSubsectionGrade @@ -76,7 +76,7 @@ from openedx.core.djangoapps.credit.tests.factories import CreditCourseFactory from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme from openedx.core.djangoapps.util.testing import ContentGroupTestCase, TestConditionalContent from openedx.core.lib.teams_config import TeamsConfig -from common.djangoapps.student.models import ALLOWEDTOENROLL_TO_ENROLLED, CourseEnrollment, CourseEnrollmentAllowed, ManualEnrollmentAudit +from common.djangoapps.student.models import ALLOWEDTOENROLL_TO_ENROLLED, CourseEnrollment, CourseEnrollmentAllowed, ManualEnrollmentAudit # lint-amnesty, pylint: disable=line-too-long, unused-import from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from lms.djangoapps.survey.models import SurveyAnswer, SurveyForm from xmodule.modulestore import ModuleStoreEnum @@ -121,7 +121,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase): Tests that CSV grade report generation works. """ def setUp(self): - super(TestInstructorGradeReport, self).setUp() + super(TestInstructorGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create() @ddt.data([u'student@example.com', u'ni\xf1o@example.com']) @@ -445,7 +445,7 @@ class TestTeamGradeReport(InstructorGradeReportTestCase): """ Test that teams appear correctly in the grade report when it is enabled for the course. """ def setUp(self): - super(TestTeamGradeReport, self).setUp() + super(TestTeamGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create(teams_configuration=_TEAMS_CONFIG) self.student1 = UserFactory.create() CourseEnrollment.enroll(self.student1, self.course.id) @@ -485,7 +485,7 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskModuleTestCase): """ def setUp(self): - super(TestProblemResponsesReport, self).setUp() + super(TestProblemResponsesReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.initialize_course() self.instructor = self.create_instructor('instructor') self.student = self.create_student('student') @@ -811,7 +811,7 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase): Test that the problem CSV generation works. """ def setUp(self): - super(TestProblemGradeReport, self).setUp() + super(TestProblemGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.initialize_course() # Add unicode data to CSV even though unicode usernames aren't # technically possible in openedx. @@ -959,7 +959,7 @@ class TestProblemReportSplitTestContent(TestReportMixin, TestConditionalContent, OPTION_2 = 'Option 2' def setUp(self): - super(TestProblemReportSplitTestContent, self).setUp() + super(TestProblemReportSplitTestContent, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.problem_a_url = u'problem_a_url' self.problem_b_url = u'problem_b_url' self.define_option_problem(self.problem_a_url, parent=self.vertical_a) @@ -1088,7 +1088,7 @@ class TestProblemReportCohortedContent(TestReportMixin, ContentGroupTestCase, In Test the problem report on a course that has cohorted content. """ def setUp(self): - super(TestProblemReportCohortedContent, self).setUp() + super(TestProblemReportCohortedContent, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # construct cohorted problems to work on. self.add_course_content() vertical = ItemFactory.create( @@ -1184,7 +1184,7 @@ class TestCourseSurveyReport(TestReportMixin, InstructorTaskCourseTestCase): Tests that Course Survey report generation works. """ def setUp(self): - super(TestCourseSurveyReport, self).setUp() + super(TestCourseSurveyReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create() self.question1 = "question1" @@ -1279,7 +1279,7 @@ class TestStudentReport(TestReportMixin, InstructorTaskCourseTestCase): Tests that CSV student profile report generation works. """ def setUp(self): - super(TestStudentReport, self).setUp() + super(TestStudentReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create() def test_success(self): @@ -1323,7 +1323,7 @@ class TestTeamStudentReport(TestReportMixin, InstructorTaskCourseTestCase): "Test the student report when including teams information. " def setUp(self): - super(TestTeamStudentReport, self).setUp() + super(TestTeamStudentReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create(teams_configuration=_TEAMS_CONFIG) self.student1 = UserFactory.create() CourseEnrollment.enroll(self.student1, self.course.id) @@ -1393,7 +1393,7 @@ class TestListMayEnroll(TestReportMixin, InstructorTaskCourseTestCase): ) def setUp(self): - super(TestListMayEnroll, self).setUp() + super(TestListMayEnroll, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create() def test_success(self): @@ -1431,7 +1431,7 @@ class MockDefaultStorage(object): def open(self, file_name): """Mock out DefaultStorage.open with standard python open""" - return open(file_name) # pylint: disable=open-builtin + return open(file_name) # lint-amnesty, pylint: disable=bad-option-value, open-builtin @patch('lms.djangoapps.instructor_task.tasks_helper.misc.DefaultStorage', new=MockDefaultStorage) @@ -1440,7 +1440,7 @@ class TestCohortStudents(TestReportMixin, InstructorTaskCourseTestCase): Tests that bulk student cohorting works. """ def setUp(self): - super(TestCohortStudents, self).setUp() + super(TestCohortStudents, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create() self.cohort_1 = CohortFactory(course_id=self.course.id, name='Cohort 1') @@ -1699,7 +1699,7 @@ class TestGradeReport(TestReportMixin, InstructorTaskModuleTestCase): Test that grade report has correct grade values. """ def setUp(self): - super(TestGradeReport, self).setUp() + super(TestGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.create_course() self.student = self.create_student(u'üser_1') @@ -1858,7 +1858,7 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas Test that grade report has correct user enrollment, verification, and certificate information. """ def setUp(self): - super(TestGradeReportEnrollmentAndCertificateInfo, self).setUp() + super(TestGradeReportEnrollmentAndCertificateInfo, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments today = datetime.now(UTC) course_factory_kwargs = { @@ -2010,7 +2010,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase): ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache'] def setUp(self): - super(TestCertificateGeneration, self).setUp() + super(TestCertificateGeneration, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.initialize_course() def test_certificate_generation_for_students(self): @@ -2569,13 +2569,13 @@ class TestInstructorOra2Report(SharedModuleStoreTestCase): cls.course = CourseFactory.create() def setUp(self): - super(TestInstructorOra2Report, self).setUp() + super(TestInstructorOra2Report, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.current_task = Mock() self.current_task.update_state = Mock() def tearDown(self): - super(TestInstructorOra2Report, self).tearDown() + super(TestInstructorOra2Report, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments if os.path.exists(settings.GRADES_DOWNLOAD['ROOT_PATH']): shutil.rmtree(settings.GRADES_DOWNLOAD['ROOT_PATH']) diff --git a/lms/djangoapps/instructor_task/views.py b/lms/djangoapps/instructor_task/views.py index 914dc23571..9f01008c40 100644 --- a/lms/djangoapps/instructor_task/views.py +++ b/lms/djangoapps/instructor_task/views.py @@ -1,4 +1,4 @@ - + # lint-amnesty, pylint: disable=missing-module-docstring import json import logging @@ -13,7 +13,7 @@ from lms.djangoapps.instructor_task.models import PROGRESS log = logging.getLogger(__name__) # return status for completed tasks and tasks in progress -STATES_WITH_STATUS = [state for state in READY_STATES] + [PROGRESS] +STATES_WITH_STATUS = [state for state in READY_STATES] + [PROGRESS] # lint-amnesty, pylint: disable=unnecessary-comprehension def _get_instructor_task_status(task_id): @@ -84,10 +84,10 @@ def instructor_task_status(request): if task_output is not None: output[task_id] = task_output - return HttpResponse(json.dumps(output, indent=4)) + return HttpResponse(json.dumps(output, indent=4)) # lint-amnesty, pylint: disable=http-response-with-json-dumps -def get_task_completion_info(instructor_task): +def get_task_completion_info(instructor_task): # lint-amnesty, pylint: disable=too-many-statements """ Construct progress message from progress information in InstructorTask entry. @@ -125,7 +125,7 @@ def get_task_completion_info(instructor_task): log.warning(fmt.format(instructor_task.task_id, instructor_task.task_output)) return (succeeded, _("No progress status information available")) - action_name = _(task_output['action_name']) + action_name = _(task_output['action_name']) # lint-amnesty, pylint: disable=translation-of-non-string num_attempted = task_output['attempted'] num_total = task_output['total'] @@ -152,19 +152,19 @@ def get_task_completion_info(instructor_task): if instructor_task.task_state == PROGRESS: # special message for providing progress updates: - # Translators: {action} is a past-tense verb that is localized separately. {attempted} and {succeeded} are counts. + # Translators: {action} is a past-tense verb that is localized separately. {attempted} and {succeeded} are counts. # lint-amnesty, pylint: disable=line-too-long msg_format = _(u"Progress: {action} {succeeded} of {attempted} so far") elif student is not None and problem_url is not None: # this reports on actions on problems for a particular student: if num_attempted == 0: - # Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier. + # Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier. # lint-amnesty, pylint: disable=line-too-long msg_format = _(u"Unable to find submission to be {action} for student '{student}'") elif num_succeeded == 0: - # Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier. + # Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier. # lint-amnesty, pylint: disable=line-too-long msg_format = _(u"Problem failed to be {action} for student '{student}'") else: succeeded = True - # Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier. + # Translators: {action} is a past-tense verb that is localized separately. {student} is a student identifier. # lint-amnesty, pylint: disable=line-too-long msg_format = _(u"Problem successfully {action} for student '{student}'") elif student is not None and entrance_exam_url is not None: # this reports on actions on entrance exam for a particular student: @@ -190,7 +190,7 @@ def get_task_completion_info(instructor_task): # Translators: {action} is a past-tense verb that is localized separately. {attempted} is a count. msg_format = _(u"Problem successfully {action} for {attempted} students") else: # num_succeeded < num_attempted - # Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts. + # Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts. # lint-amnesty, pylint: disable=line-too-long msg_format = _(u"Problem {action} for {succeeded} of {attempted} students") elif email_id is not None: # this reports on actions on bulk emails @@ -205,11 +205,11 @@ def get_task_completion_info(instructor_task): # Translators: {action} is a past-tense verb that is localized separately. {attempted} is a count. msg_format = _(u"Message successfully {action} for {attempted} recipients") else: # num_succeeded < num_attempted - # Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts. + # Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts. # lint-amnesty, pylint: disable=line-too-long msg_format = _(u"Message {action} for {succeeded} of {attempted} recipients") else: # provide a default: - # Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts. + # Translators: {action} is a past-tense verb that is localized separately. {succeeded} and {attempted} are counts. # lint-amnesty, pylint: disable=line-too-long msg_format = _(u"Status: {action} {succeeded} of {attempted}") if num_skipped > 0: diff --git a/lms/djangoapps/learner_dashboard/programs.py b/lms/djangoapps/learner_dashboard/programs.py index 7b789da289..85316561c8 100644 --- a/lms/djangoapps/learner_dashboard/programs.py +++ b/lms/djangoapps/learner_dashboard/programs.py @@ -8,7 +8,7 @@ import json from django.http import Http404 from django.template.loader import render_to_string from django.urls import reverse -from django.utils.translation import get_language_bidi, ugettext_lazy as _ +from django.utils.translation import get_language_bidi, ugettext_lazy as _ # lint-amnesty, pylint: disable=unused-import from web_fragments.fragment import Fragment from lms.djangoapps.commerce.utils import EcommerceService @@ -71,7 +71,7 @@ class ProgramDetailsFragmentView(EdxFragmentView): Render the program details fragment. """ - def render_to_fragment(self, request, program_uuid, **kwargs): + def render_to_fragment(self, request, program_uuid, **kwargs): # lint-amnesty, pylint: disable=arguments-differ """View details about a specific program.""" programs_config = kwargs.get('programs_config') or ProgramsApiConfig.current() if not programs_config.enabled or not request.user.is_authenticated: diff --git a/lms/djangoapps/learner_dashboard/tests/test_programs.py b/lms/djangoapps/learner_dashboard/tests/test_programs.py index 8af51b1749..75490bcb90 100644 --- a/lms/djangoapps/learner_dashboard/tests/test_programs.py +++ b/lms/djangoapps/learner_dashboard/tests/test_programs.py @@ -60,7 +60,7 @@ class TestProgramListing(ProgramsApiConfigMixin, SharedModuleStoreTestCase): super(TestProgramListing, cls).setUpClass() cls.course = ModuleStoreCourseFactory() - course_run = CourseRunFactory(key=six.text_type(cls.course.id)) + course_run = CourseRunFactory(key=six.text_type(cls.course.id)) # lint-amnesty, pylint: disable=no-member course = CourseFactory(course_runs=[course_run]) cls.first_program = ProgramFactory(courses=[course]) @@ -69,7 +69,7 @@ class TestProgramListing(ProgramsApiConfigMixin, SharedModuleStoreTestCase): cls.data = sorted([cls.first_program, cls.second_program], key=cls.program_sort_key) def setUp(self): - super(TestProgramListing, self).setUp() + super(TestProgramListing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() self.client.login(username=self.user.username, password=self.password) @@ -140,7 +140,7 @@ class TestProgramListing(ProgramsApiConfigMixin, SharedModuleStoreTestCase): self.create_programs_config() mock_get_programs.return_value = self.data - CourseEnrollmentFactory(user=self.user, course_id=self.course.id) + CourseEnrollmentFactory(user=self.user, course_id=self.course.id) # lint-amnesty, pylint: disable=no-member response = self.client.get(self.url) actual = load_serialized_data(response, 'programsData') @@ -181,7 +181,7 @@ class TestProgramListing(ProgramsApiConfigMixin, SharedModuleStoreTestCase): self.create_programs_config() mock_get_programs.return_value = self.data - CourseEnrollmentFactory(user=self.user, course_id=self.course.id) + CourseEnrollmentFactory(user=self.user, course_id=self.course.id) # lint-amnesty, pylint: disable=no-member response = self.client.get(self.url) actual = load_serialized_data(response, 'programsData') @@ -208,17 +208,17 @@ class TestProgramDetails(ProgramsApiConfigMixin, CatalogIntegrationMixin, Shared super(TestProgramDetails, cls).setUpClass() modulestore_course = ModuleStoreCourseFactory() - course_run = CourseRunFactory(key=six.text_type(modulestore_course.id)) + course_run = CourseRunFactory(key=six.text_type(modulestore_course.id)) # lint-amnesty, pylint: disable=no-member course = CourseFactory(course_runs=[course_run]) cls.program_data = ProgramFactory(uuid=cls.program_uuid, courses=[course]) cls.pathway_data = PathwayFactory() cls.program_data['pathway_ids'] = [cls.pathway_data['id']] cls.pathway_data['program_uuids'] = [cls.program_data['uuid']] - del cls.pathway_data['programs'] + del cls.pathway_data['programs'] # lint-amnesty, pylint: disable=unsupported-delete-operation def setUp(self): - super(TestProgramDetails, self).setUp() + super(TestProgramDetails, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() self.client.login(username=self.user.username, password=self.password) From 92dfde7ca127bdb6bb42e0898b0c5c3a59c55eae Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Mon, 1 Feb 2021 19:46:04 +0500 Subject: [PATCH 02/19] BOM-2282 Apply pylint-amnesty. --- lms/djangoapps/instructor_task/__init__.py | 2 +- lms/djangoapps/instructor_task/subtasks.py | 2 +- lms/djangoapps/instructor_task/views.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/instructor_task/__init__.py b/lms/djangoapps/instructor_task/__init__.py index d29347c62a..86f8aed7af 100644 --- a/lms/djangoapps/instructor_task/__init__.py +++ b/lms/djangoapps/instructor_task/__init__.py @@ -1,2 +1,2 @@ - # lint-amnesty, pylint: disable=django-not-configured, missing-module-docstring +# lint-amnesty, pylint: disable=django-not-configured, missing-module-docstring default_app_config = 'lms.djangoapps.instructor_task.apps.InstructorTaskConfig' diff --git a/lms/djangoapps/instructor_task/subtasks.py b/lms/djangoapps/instructor_task/subtasks.py index cb93248b6e..ca73c78d2b 100644 --- a/lms/djangoapps/instructor_task/subtasks.py +++ b/lms/djangoapps/instructor_task/subtasks.py @@ -273,7 +273,7 @@ def initialize_subtask_info(entry, action_name, total_num, subtask_id_list): return task_progress - # lint-amnesty, pylint: disable=bad-continuation, bad-option-value +# lint-amnesty, pylint: disable=bad-continuation, bad-option-value def queue_subtasks_for_query( entry, action_name, diff --git a/lms/djangoapps/instructor_task/views.py b/lms/djangoapps/instructor_task/views.py index 9f01008c40..acd8130df6 100644 --- a/lms/djangoapps/instructor_task/views.py +++ b/lms/djangoapps/instructor_task/views.py @@ -1,4 +1,4 @@ - # lint-amnesty, pylint: disable=missing-module-docstring +# lint-amnesty, pylint: disable=missing-module-docstring import json import logging From d24a1401ae21c94523172458d1e7a2c359092c13 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Tue, 2 Feb 2021 10:47:24 +0500 Subject: [PATCH 03/19] BOM-2282 Apply pylint-amnesty. --- lms/djangoapps/instructor_task/subtasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/instructor_task/subtasks.py b/lms/djangoapps/instructor_task/subtasks.py index ca73c78d2b..62ba7ec6cc 100644 --- a/lms/djangoapps/instructor_task/subtasks.py +++ b/lms/djangoapps/instructor_task/subtasks.py @@ -67,7 +67,7 @@ def track_memory_usage(metric, course_id): # lint-amnesty, pylint: disable=unus def _generate_items_for_subtask( - item_querysets, # lint-amnesty, pylint: disable=bad-continuation, bad-option-value + item_querysets, # lint-amnesty, # pylint: disable=bad-option-value item_fields, total_num_items, items_per_task, @@ -273,7 +273,7 @@ def initialize_subtask_info(entry, action_name, total_num, subtask_id_list): return task_progress -# lint-amnesty, pylint: disable=bad-continuation, bad-option-value +# lint-amnesty, # pylint: disable=bad-option-value def queue_subtasks_for_query( entry, action_name, From 28307c0a0a9493673fde66172ee71daf7ba3293b Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Tue, 2 Feb 2021 11:31:34 +0500 Subject: [PATCH 04/19] BOM-2283 Apply pylint-amnesty. --- lms/djangoapps/lms_initialization/__init__.py | 2 +- lms/djangoapps/lms_xblock/field_data.py | 2 +- lms/djangoapps/lms_xblock/mixin.py | 4 +-- lms/djangoapps/lms_xblock/runtime.py | 6 ++-- .../lms_xblock/test/test_runtime.py | 14 +++++----- lms/djangoapps/lti_provider/__init__.py | 2 +- .../commands/tests/test_resend_lti_scores.py | 2 +- lms/djangoapps/lti_provider/models.py | 2 +- lms/djangoapps/lti_provider/outcomes.py | 28 +++++++++---------- .../lti_provider/signature_validator.py | 10 +++---- lms/djangoapps/lti_provider/tasks.py | 2 +- .../lti_provider/tests/test_outcomes.py | 6 ++-- .../tests/test_signature_validator.py | 6 ++-- .../lti_provider/tests/test_tasks.py | 4 +-- .../lti_provider/tests/test_users.py | 14 +++++----- .../lti_provider/tests/test_views.py | 2 +- lms/djangoapps/lti_provider/users.py | 2 +- lms/djangoapps/lti_provider/views.py | 2 +- 18 files changed, 55 insertions(+), 55 deletions(-) diff --git a/lms/djangoapps/lms_initialization/__init__.py b/lms/djangoapps/lms_initialization/__init__.py index a89aa1b1b1..807aac125b 100644 --- a/lms/djangoapps/lms_initialization/__init__.py +++ b/lms/djangoapps/lms_initialization/__init__.py @@ -1,3 +1,3 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured Initialization app for the LMS """ diff --git a/lms/djangoapps/lms_xblock/field_data.py b/lms/djangoapps/lms_xblock/field_data.py index 6866c32187..3c485b0718 100644 --- a/lms/djangoapps/lms_xblock/field_data.py +++ b/lms/djangoapps/lms_xblock/field_data.py @@ -24,7 +24,7 @@ class LmsFieldData(SplitFieldData): self._authored_data = authored_data self._student_data = student_data - super(LmsFieldData, self).__init__({ + super(LmsFieldData, self).__init__({ # lint-amnesty, pylint: disable=super-with-arguments Scope.content: authored_data, Scope.settings: authored_data, Scope.parent: authored_data, diff --git a/lms/djangoapps/lms_xblock/mixin.py b/lms/djangoapps/lms_xblock/mixin.py index 1f34e8d2ed..2f02074a3b 100644 --- a/lms/djangoapps/lms_xblock/mixin.py +++ b/lms/djangoapps/lms_xblock/mixin.py @@ -198,7 +198,7 @@ class LmsBlockMixin(XBlockMixin): Validates the state of this xblock instance. """ _ = self.runtime.service(self, "i18n").ugettext - validation = super(LmsBlockMixin, self).validate() + validation = super(LmsBlockMixin, self).validate() # lint-amnesty, pylint: disable=super-with-arguments has_invalid_user_partitions = False has_invalid_groups = False block_is_unit = is_unit(self) @@ -253,7 +253,7 @@ class LmsBlockMixin(XBlockMixin): Publish completion data from the front end. """ completion_service = self.runtime.service(self, 'completion') - if completion_service is None: + if completion_service is None: # lint-amnesty, pylint: disable=no-else-raise raise JsonHandlerError(500, u"No completion service found") elif not completion_service.completion_tracking_enabled(): raise JsonHandlerError(404, u"Completion tracking is not enabled and API calls are unexpected") diff --git a/lms/djangoapps/lms_xblock/runtime.py b/lms/djangoapps/lms_xblock/runtime.py index 2cc72782c7..3e64229d63 100644 --- a/lms/djangoapps/lms_xblock/runtime.py +++ b/lms/djangoapps/lms_xblock/runtime.py @@ -166,9 +166,9 @@ class LmsModuleSystem(ModuleSystem): # pylint: disable=abstract-method services['teams'] = TeamsService() services['teams_configuration'] = TeamsConfigurationService() services['call_to_action'] = CallToActionService() - super(LmsModuleSystem, self).__init__(**kwargs) + super(LmsModuleSystem, self).__init__(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments - def handler_url(self, *args, **kwargs): + def handler_url(self, *args, **kwargs): # lint-amnesty, pylint: disable=signature-differs """ Implement the XBlock runtime handler_url interface. @@ -244,6 +244,6 @@ class LmsModuleSystem(ModuleSystem): # pylint: disable=abstract-method # (see https://openedx.atlassian.net/browse/TE-811) return [ aside_type - for aside_type in super(LmsModuleSystem, self).applicable_aside_types(block) + for aside_type in super(LmsModuleSystem, self).applicable_aside_types(block) # lint-amnesty, pylint: disable=super-with-arguments if aside_type != 'acid_aside' ] diff --git a/lms/djangoapps/lms_xblock/test/test_runtime.py b/lms/djangoapps/lms_xblock/test/test_runtime.py index a24078cb56..d5a252439e 100644 --- a/lms/djangoapps/lms_xblock/test/test_runtime.py +++ b/lms/djangoapps/lms_xblock/test/test_runtime.py @@ -29,19 +29,19 @@ class BlockMock(Mock): """ A test handler method. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def handler1(self, _context): """ A test handler method. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def handler_a(self, _context): """ A test handler method. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass @property def location(self): @@ -54,7 +54,7 @@ class TestHandlerUrl(TestCase): """Test the LMS handler_url""" def setUp(self): - super(TestHandlerUrl, self).setUp() + super(TestHandlerUrl, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.block = BlockMock(name='block', scope_ids=ScopeIds(None, None, None, 'dummy')) self.course_key = CourseLocator("org", "course", "run") self.runtime = LmsModuleSystem( @@ -119,7 +119,7 @@ class TestUserServiceAPI(TestCase): """Test the user service interface""" def setUp(self): - super(TestUserServiceAPI, self).setUp() + super(TestUserServiceAPI, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_id = CourseLocator("org", "course", "run") self.user = UserFactory.create() @@ -169,7 +169,7 @@ class TestBadgingService(ModuleStoreTestCase): """Test the badging service interface""" def setUp(self): - super(TestBadgingService, self).setUp() + super(TestBadgingService, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_id = CourseKey.from_string('course-v1:org+course+run') self.mock_block = Mock() @@ -235,7 +235,7 @@ class TestI18nService(ModuleStoreTestCase): def setUp(self): """ Setting up tests """ - super(TestI18nService, self).setUp() + super(TestI18nService, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create() self.test_language = 'dummy language' self.runtime = LmsModuleSystem( diff --git a/lms/djangoapps/lti_provider/__init__.py b/lms/djangoapps/lti_provider/__init__.py index ccf384160d..14d9b6518a 100644 --- a/lms/djangoapps/lti_provider/__init__.py +++ b/lms/djangoapps/lti_provider/__init__.py @@ -1,4 +1,4 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured The LTI Provider app gives a way to launch edX content via a campus LMS platform. LTI is a standard protocol for connecting educational tools, defined by IMS: diff --git a/lms/djangoapps/lti_provider/management/commands/tests/test_resend_lti_scores.py b/lms/djangoapps/lti_provider/management/commands/tests/test_resend_lti_scores.py index 18bbfbfbbc..7c7d70cc05 100644 --- a/lms/djangoapps/lti_provider/management/commands/tests/test_resend_lti_scores.py +++ b/lms/djangoapps/lti_provider/management/commands/tests/test_resend_lti_scores.py @@ -64,7 +64,7 @@ class CommandExecutionTestCase(SharedModuleStoreTestCase): cls.lti_block = u'block-v1:edX+lti_provider+3000+type@chapter+block@chapter_2' def setUp(self): - super(CommandExecutionTestCase, self).setUp() + super(CommandExecutionTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() self.user2 = UserFactory(username=u'anotheruser') self.client.login(username=self.user.username, password=u'test') diff --git a/lms/djangoapps/lti_provider/models.py b/lms/djangoapps/lti_provider/models.py index 0d1f0a6c9b..a096917102 100644 --- a/lms/djangoapps/lti_provider/models.py +++ b/lms/djangoapps/lti_provider/models.py @@ -12,7 +12,7 @@ changes. To do that, import logging -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.db import models from opaque_keys.edx.django.models import CourseKeyField, UsageKeyField diff --git a/lms/djangoapps/lti_provider/outcomes.py b/lms/djangoapps/lti_provider/outcomes.py index 7573806148..9463cbff94 100644 --- a/lms/djangoapps/lti_provider/outcomes.py +++ b/lms/djangoapps/lti_provider/outcomes.py @@ -71,23 +71,23 @@ def generate_replace_result_xml(result_sourcedid, score): """ # Pylint doesn't recognize members in the LXML module elem = ElementMaker(nsmap={None: 'http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0'}) - xml = elem.imsx_POXEnvelopeRequest( - elem.imsx_POXHeader( - elem.imsx_POXRequestHeaderInfo( - elem.imsx_version('V1.0'), - elem.imsx_messageIdentifier(str(uuid.uuid4())) + xml = elem.imsx_POXEnvelopeRequest( # lint-amnesty, pylint: disable=no-member + elem.imsx_POXHeader( # lint-amnesty, pylint: disable=no-member + elem.imsx_POXRequestHeaderInfo( # lint-amnesty, pylint: disable=no-member + elem.imsx_version('V1.0'), # lint-amnesty, pylint: disable=no-member + elem.imsx_messageIdentifier(str(uuid.uuid4())) # lint-amnesty, pylint: disable=no-member ) ), - elem.imsx_POXBody( - elem.replaceResultRequest( - elem.resultRecord( - elem.sourcedGUID( - elem.sourcedId(result_sourcedid) + elem.imsx_POXBody( # lint-amnesty, pylint: disable=no-member + elem.replaceResultRequest( # lint-amnesty, pylint: disable=no-member + elem.resultRecord( # lint-amnesty, pylint: disable=no-member + elem.sourcedGUID( # lint-amnesty, pylint: disable=no-member + elem.sourcedId(result_sourcedid) # lint-amnesty, pylint: disable=no-member ), - elem.result( - elem.resultScore( - elem.language('en'), - elem.textString(str(score)) + elem.result( # lint-amnesty, pylint: disable=no-member + elem.resultScore( # lint-amnesty, pylint: disable=no-member + elem.language('en'), # lint-amnesty, pylint: disable=no-member + elem.textString(str(score)) # lint-amnesty, pylint: disable=no-member ) ) ) diff --git a/lms/djangoapps/lti_provider/signature_validator.py b/lms/djangoapps/lti_provider/signature_validator.py index 4e1a88105f..b48ca9615e 100644 --- a/lms/djangoapps/lti_provider/signature_validator.py +++ b/lms/djangoapps/lti_provider/signature_validator.py @@ -18,7 +18,7 @@ class SignatureValidator(RequestValidator): """ def __init__(self, lti_consumer): - super(SignatureValidator, self).__init__() + super(SignatureValidator, self).__init__() # lint-amnesty, pylint: disable=super-with-arguments self.endpoint = SignatureOnlyEndpoint(self) self.lti_consumer = lti_consumer @@ -31,7 +31,7 @@ class SignatureValidator(RequestValidator): # on the platform. enforce_ssl = False - def check_client_key(self, key): + def check_client_key(self, key): # lint-amnesty, pylint: disable=arguments-differ """ Verify that the key supplied by the LTI consumer is valid for an LTI launch. This method is only concerned with the structure of the key; @@ -141,13 +141,13 @@ class SignatureValidator(RequestValidator): """ raise NotImplementedError - def dummy_access_token(self): + def dummy_access_token(self): # lint-amnesty, pylint: disable=invalid-overridden-method """ Unused abstract method from super class. See documentation in RequestValidator """ raise NotImplementedError - def dummy_client(self): + def dummy_client(self): # lint-amnesty, pylint: disable=invalid-overridden-method """ Unused abstract method from super class. See documentation in RequestValidator """ @@ -172,7 +172,7 @@ class SignatureValidator(RequestValidator): """ raise NotImplementedError - def dummy_request_token(self): + def dummy_request_token(self): # lint-amnesty, pylint: disable=invalid-overridden-method """ Unused abstract method from super class. See documentation in RequestValidator """ diff --git a/lms/djangoapps/lti_provider/tasks.py b/lms/djangoapps/lti_provider/tasks.py index 4b0d4cb4b4..60c19b5923 100644 --- a/lms/djangoapps/lti_provider/tasks.py +++ b/lms/djangoapps/lti_provider/tasks.py @@ -5,7 +5,7 @@ Asynchronous tasks for the LTI provider app. import logging -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 import lms.djangoapps.lti_provider.outcomes as outcomes diff --git a/lms/djangoapps/lti_provider/tests/test_outcomes.py b/lms/djangoapps/lti_provider/tests/test_outcomes.py index cc0f4cac55..416de30292 100644 --- a/lms/djangoapps/lti_provider/tests/test_outcomes.py +++ b/lms/djangoapps/lti_provider/tests/test_outcomes.py @@ -21,7 +21,7 @@ class StoreOutcomeParametersTest(TestCase): """ def setUp(self): - super(StoreOutcomeParametersTest, self).setUp() + super(StoreOutcomeParametersTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create() self.course_key = CourseLocator( org='some_org', @@ -135,7 +135,7 @@ class SignAndSendReplaceResultTest(TestCase): """ def setUp(self): - super(SignAndSendReplaceResultTest, self).setUp() + super(SignAndSendReplaceResultTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_key = CourseLocator( org='some_org', course='some_course', @@ -298,7 +298,7 @@ class TestAssignmentsForProblem(ModuleStoreTestCase): """ def setUp(self): - super(TestAssignmentsForProblem, self).setUp() + super(TestAssignmentsForProblem, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create() self.user_id = self.user.id self.outcome_service = self.create_outcome_service('outcomes') diff --git a/lms/djangoapps/lti_provider/tests/test_signature_validator.py b/lms/djangoapps/lti_provider/tests/test_signature_validator.py index 9d2e8b0b89..57911b0069 100644 --- a/lms/djangoapps/lti_provider/tests/test_signature_validator.py +++ b/lms/djangoapps/lti_provider/tests/test_signature_validator.py @@ -30,7 +30,7 @@ class ClientKeyValidatorTest(TestCase): """ def setUp(self): - super(ClientKeyValidatorTest, self).setUp() + super(ClientKeyValidatorTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.lti_consumer = get_lti_consumer() def test_valid_client_key(self): @@ -60,7 +60,7 @@ class NonceValidatorTest(TestCase): """ def setUp(self): - super(NonceValidatorTest, self).setUp() + super(NonceValidatorTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.lti_consumer = get_lti_consumer() def test_valid_nonce(self): @@ -91,7 +91,7 @@ class SignatureValidatorTest(TestCase): """ def setUp(self): - super(SignatureValidatorTest, self).setUp() + super(SignatureValidatorTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.lti_consumer = get_lti_consumer() def test_get_existing_client_secret(self): diff --git a/lms/djangoapps/lti_provider/tests/test_tasks.py b/lms/djangoapps/lti_provider/tests/test_tasks.py index 6fc387d2fa..453f9493d5 100644 --- a/lms/djangoapps/lti_provider/tests/test_tasks.py +++ b/lms/djangoapps/lti_provider/tests/test_tasks.py @@ -19,7 +19,7 @@ class BaseOutcomeTest(TestCase): Super type for tests of both the leaf and composite outcome celery tasks. """ def setUp(self): - super(BaseOutcomeTest, self).setUp() + super(BaseOutcomeTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_key = CourseLocator( org='some_org', course='some_course', @@ -96,7 +96,7 @@ class SendCompositeOutcomeTest(BaseOutcomeTest): """ def setUp(self): - super(SendCompositeOutcomeTest, self).setUp() + super(SendCompositeOutcomeTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.descriptor = MagicMock() self.descriptor.location = BlockUsageLocator( course_key=self.course_key, diff --git a/lms/djangoapps/lti_provider/tests/test_users.py b/lms/djangoapps/lti_provider/tests/test_users.py index 0b083434a5..132cb7704c 100644 --- a/lms/djangoapps/lti_provider/tests/test_users.py +++ b/lms/djangoapps/lti_provider/tests/test_users.py @@ -5,7 +5,7 @@ Tests for the LTI user management functionality import string -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import PermissionDenied from django.test import TestCase from django.test.client import RequestFactory @@ -14,7 +14,7 @@ from six.moves import range from .. import users from ..models import LtiConsumer, LtiUser -from common.djangoapps.student.tests.factories import UserFactory +from common.djangoapps.student.tests.factories import UserFactory # lint-amnesty, pylint: disable=wrong-import-order class UserManagementHelperTest(TestCase): @@ -23,7 +23,7 @@ class UserManagementHelperTest(TestCase): """ def setUp(self): - super(UserManagementHelperTest, self).setUp() + super(UserManagementHelperTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.request = RequestFactory().post('/') self.old_user = UserFactory.create() self.new_user = UserFactory.create() @@ -66,7 +66,7 @@ class UserManagementHelperTest(TestCase): username = users.generate_random_edx_username() self.assertLessEqual(len(username), 30, 'Username too long') # Check that the username contains only allowable characters - for char in range(len(username)): + for char in range(len(username)): # lint-amnesty, pylint: disable=consider-using-enumerate self.assertIn( username[char], string.ascii_letters + string.digits, u"Username has forbidden character '{}'".format(username[char]) @@ -81,7 +81,7 @@ class AuthenticateLtiUserTest(TestCase): """ def setUp(self): - super(AuthenticateLtiUserTest, self).setUp() + super(AuthenticateLtiUserTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.lti_consumer = LtiConsumer( consumer_name='TestConsumer', consumer_key='TestKey', @@ -148,7 +148,7 @@ class CreateLtiUserTest(TestCase): """ def setUp(self): - super(CreateLtiUserTest, self).setUp() + super(CreateLtiUserTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.lti_consumer = LtiConsumer( consumer_name='TestConsumer', consumer_key='TestKey', @@ -185,7 +185,7 @@ class LtiBackendTest(TestCase): """ def setUp(self): - super(LtiBackendTest, self).setUp() + super(LtiBackendTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.edx_user = UserFactory.create() self.edx_user.save() self.lti_consumer = LtiConsumer( diff --git a/lms/djangoapps/lti_provider/tests/test_views.py b/lms/djangoapps/lti_provider/tests/test_views.py index 5192bfaf6f..8b0b247717 100644 --- a/lms/djangoapps/lti_provider/tests/test_views.py +++ b/lms/djangoapps/lti_provider/tests/test_views.py @@ -68,7 +68,7 @@ class LtiTestMixin(object): """ @patch.dict('django.conf.settings.FEATURES', {'ENABLE_LTI_PROVIDER': True}) def setUp(self): - super(LtiTestMixin, self).setUp() + super(LtiTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Always accept the OAuth signature self.mock_verify = MagicMock(return_value=True) patcher = patch('lms.djangoapps.lti_provider.signature_validator.SignatureValidator.verify', self.mock_verify) diff --git a/lms/djangoapps/lti_provider/users.py b/lms/djangoapps/lti_provider/users.py index 3ff26f99a6..775c6832b0 100644 --- a/lms/djangoapps/lti_provider/users.py +++ b/lms/djangoapps/lti_provider/users.py @@ -10,7 +10,7 @@ import uuid from django.conf import settings from django.contrib.auth import authenticate, login -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import PermissionDenied from django.db import IntegrityError, transaction from six.moves import range diff --git a/lms/djangoapps/lti_provider/views.py b/lms/djangoapps/lti_provider/views.py index cc10a368b7..dfc01c9c8c 100644 --- a/lms/djangoapps/lti_provider/views.py +++ b/lms/djangoapps/lti_provider/views.py @@ -83,7 +83,7 @@ def lti_launch(request, course_id, usage_id): usage_id, request ) - raise Http404() + raise Http404() # lint-amnesty, pylint: disable=raise-missing-from params['course_key'] = course_key params['usage_key'] = usage_key From aeca77e6337522b9001de95eb167e3392ed59894 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Tue, 2 Feb 2021 11:33:01 +0500 Subject: [PATCH 05/19] BOM-2283 Apply pylint-amnesty. --- lms/djangoapps/lms_initialization/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/lms_initialization/__init__.py b/lms/djangoapps/lms_initialization/__init__.py index 807aac125b..4901a5b848 100644 --- a/lms/djangoapps/lms_initialization/__init__.py +++ b/lms/djangoapps/lms_initialization/__init__.py @@ -1,3 +1,4 @@ -""" # lint-amnesty, pylint: disable=django-not-configured +""" +# lint-amnesty, pylint: disable=django-not-configured Initialization app for the LMS """ From 07599e930c3d5db39948ecf050001ef0d95ac2d5 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Tue, 2 Feb 2021 11:37:56 +0500 Subject: [PATCH 06/19] BOM-2284 Apply pylint-amnesty. --- .../commands/mailchimp_sync_announcements.py | 2 +- lms/djangoapps/mobile_api/__init__.py | 2 +- lms/djangoapps/mobile_api/course_info/tests.py | 2 +- lms/djangoapps/mobile_api/course_info/views.py | 4 ++-- lms/djangoapps/mobile_api/decorators.py | 2 +- lms/djangoapps/mobile_api/models.py | 4 ++-- lms/djangoapps/mobile_api/tests/test_decorator.py | 2 +- lms/djangoapps/mobile_api/tests/test_middleware.py | 2 +- .../mobile_api/tests/test_mobile_platform.py | 6 +++--- lms/djangoapps/mobile_api/testutils.py | 4 ++-- lms/djangoapps/mobile_api/users/serializers.py | 4 ++-- lms/djangoapps/mobile_api/users/tests.py | 10 +++++----- lms/djangoapps/mobile_api/users/views.py | 12 ++++++------ lms/djangoapps/monitoring/__init__.py | 2 +- 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lms/djangoapps/mailing/management/commands/mailchimp_sync_announcements.py b/lms/djangoapps/mailing/management/commands/mailchimp_sync_announcements.py index b1691e2885..0469874cc9 100644 --- a/lms/djangoapps/mailing/management/commands/mailchimp_sync_announcements.py +++ b/lms/djangoapps/mailing/management/commands/mailchimp_sync_announcements.py @@ -5,7 +5,7 @@ Synchronizes the announcement list with all active students. import logging -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.management.base import BaseCommand from .mailchimp_sync_course import connect_mailchimp, get_cleaned, get_subscribed, get_unsubscribed, subscribe_with_data diff --git a/lms/djangoapps/mobile_api/__init__.py b/lms/djangoapps/mobile_api/__init__.py index 0cb2d33a89..d419cba73a 100644 --- a/lms/djangoapps/mobile_api/__init__.py +++ b/lms/djangoapps/mobile_api/__init__.py @@ -1,3 +1,3 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured Mobile API """ diff --git a/lms/djangoapps/mobile_api/course_info/tests.py b/lms/djangoapps/mobile_api/course_info/tests.py index c378f1aa84..6055f324ad 100644 --- a/lms/djangoapps/mobile_api/course_info/tests.py +++ b/lms/djangoapps/mobile_api/course_info/tests.py @@ -24,7 +24,7 @@ class TestUpdates(MobileAPITestCase, MobileAuthTestMixin, MobileCourseAccessTest REVERSE_INFO = {'name': 'course-updates-list', 'params': ['course_id', 'api_version']} def verify_success(self, response): - super(TestUpdates, self).verify_success(response) + super(TestUpdates, self).verify_success(response) # lint-amnesty, pylint: disable=super-with-arguments self.assertEqual(response.data, []) @ddt.data( diff --git a/lms/djangoapps/mobile_api/course_info/views.py b/lms/djangoapps/mobile_api/course_info/views.py index 835099a75d..175889515c 100644 --- a/lms/djangoapps/mobile_api/course_info/views.py +++ b/lms/djangoapps/mobile_api/course_info/views.py @@ -37,7 +37,7 @@ class CourseUpdatesList(generics.ListAPIView): """ @mobile_course_access() - def list(self, request, course, *args, **kwargs): + def list(self, request, course, *args, **kwargs): # lint-amnesty, pylint: disable=arguments-differ course_updates_module = get_course_info_section_module(request, request.user, course, 'updates') update_items = get_course_update_items(course_updates_module) @@ -72,7 +72,7 @@ class CourseHandoutsList(generics.ListAPIView): """ @mobile_course_access() - def list(self, request, course, *args, **kwargs): + def list(self, request, course, *args, **kwargs): # lint-amnesty, pylint: disable=arguments-differ course_handouts_module = get_course_info_section_module(request, request.user, course, 'handouts') if course_handouts_module: if course_handouts_module.data == "
    ": diff --git a/lms/djangoapps/mobile_api/decorators.py b/lms/djangoapps/mobile_api/decorators.py index a3b1a95281..7ebdce4f05 100644 --- a/lms/djangoapps/mobile_api/decorators.py +++ b/lms/djangoapps/mobile_api/decorators.py @@ -49,7 +49,7 @@ def mobile_course_access(depth=0): if error.access_error is not None: return Response(data=error.access_error.to_json(), status=status.HTTP_404_NOT_FOUND) # Raise a 404 if the user does not have course access - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from return func(self, request, course=course, *args, **kwargs) return _wrapper diff --git a/lms/djangoapps/mobile_api/models.py b/lms/djangoapps/mobile_api/models.py index 8fe88fc9d1..4e423cc0db 100644 --- a/lms/djangoapps/mobile_api/models.py +++ b/lms/djangoapps/mobile_api/models.py @@ -85,10 +85,10 @@ class AppVersionConfig(models.Model): if utils.parsed_version(config.version) >= parsed_version: return config.expire_at - def save(self, *args, **kwargs): + def save(self, *args, **kwargs): # lint-amnesty, pylint: disable=signature-differs """ parses version into major, minor and patch versions before saving """ self.major_version, self.minor_version, self.patch_version = utils.parsed_version(self.version) - super(AppVersionConfig, self).save(*args, **kwargs) + super(AppVersionConfig, self).save(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments class IgnoreMobileAvailableFlagConfig(ConfigurationModel): diff --git a/lms/djangoapps/mobile_api/tests/test_decorator.py b/lms/djangoapps/mobile_api/tests/test_decorator.py index fb2c5cf3c6..40d6b0ca6d 100644 --- a/lms/djangoapps/mobile_api/tests/test_decorator.py +++ b/lms/djangoapps/mobile_api/tests/test_decorator.py @@ -23,7 +23,7 @@ class TestMobileAPIDecorators(TestCase): """ Test docstring of decorated function. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass self.assertIn("Test docstring of decorated function.", decorated_func.__doc__) self.assertEqual(decorated_func.__name__, "decorated_func") diff --git a/lms/djangoapps/mobile_api/tests/test_middleware.py b/lms/djangoapps/mobile_api/tests/test_middleware.py index 3cdd98bbe0..a88c7ba666 100644 --- a/lms/djangoapps/mobile_api/tests/test_middleware.py +++ b/lms/djangoapps/mobile_api/tests/test_middleware.py @@ -25,7 +25,7 @@ class TestAppVersionUpgradeMiddleware(CacheIsolationTestCase): ENABLED_CACHES = ['default'] def setUp(self): - super(TestAppVersionUpgradeMiddleware, self).setUp() + super(TestAppVersionUpgradeMiddleware, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.middleware = AppVersionUpgrade() self.set_app_version_config() diff --git a/lms/djangoapps/mobile_api/tests/test_mobile_platform.py b/lms/djangoapps/mobile_api/tests/test_mobile_platform.py index 63364e8ff6..2028c95c94 100644 --- a/lms/djangoapps/mobile_api/tests/test_mobile_platform.py +++ b/lms/djangoapps/mobile_api/tests/test_mobile_platform.py @@ -24,9 +24,9 @@ class TestMobilePlatform(TestCase): ("edX/org.test-domain.mobile (0.1.5; OS Version 9.2 (Build 13C75))", "iOS", "0.1.5"), ("Dalvik/2.1.0 (Linux; U; Android 5.1; Nexus 5 Build/LMY47I) edX/org.edx.mobile/1.1.1", "Android", "1.1.1"), ("Dalvik/2.1.0 (Linux; U; Android 5.1; Nexus 5 Build/LMY47I) edX/org.edx.mobile/3.3.3.X", "Android", "3.3.3.X"), - ("Dalvik/2.1.0 (Linux; U; Android 9; MI 6 MIUI/V11.0.3.0.PCAMIXM) edX/org.edx.mobile/2.17.1", "Android", "2.17.1"), - ("Dalvik/2.1.0 (Linux; U; Android 9; JKM-AL00a Build/HUAWEIJKM-AL00a) edX/org.edx.mobile/2.8.1", "Android", "2.8.1"), - ("Dalvik/2.1.0 (Linux; U; Android 8.1.0; CPH1803 Build/OPM1.171019.026) edX/org.edx.mobile/2.18.1", "Android", "2.18.1"), + ("Dalvik/2.1.0 (Linux; U; Android 9; MI 6 MIUI/V11.0.3.0.PCAMIXM) edX/org.edx.mobile/2.17.1", "Android", "2.17.1"), # lint-amnesty, pylint: disable=line-too-long + ("Dalvik/2.1.0 (Linux; U; Android 9; JKM-AL00a Build/HUAWEIJKM-AL00a) edX/org.edx.mobile/2.8.1", "Android", "2.8.1"), # lint-amnesty, pylint: disable=line-too-long + ("Dalvik/2.1.0 (Linux; U; Android 8.1.0; CPH1803 Build/OPM1.171019.026) edX/org.edx.mobile/2.18.1", "Android", "2.18.1"), # lint-amnesty, pylint: disable=line-too-long ) @ddt.unpack def test_platform_instance(self, user_agent, platform_name, version): diff --git a/lms/djangoapps/mobile_api/testutils.py b/lms/djangoapps/mobile_api/testutils.py index f344e5b3a2..820672d1df 100644 --- a/lms/djangoapps/mobile_api/testutils.py +++ b/lms/djangoapps/mobile_api/testutils.py @@ -43,7 +43,7 @@ class MobileAPITestCase(ModuleStoreTestCase, APITestCase): They may also override any of the methods defined in this class to control the behavior of the TestMixins. """ def setUp(self): - super(MobileAPITestCase, self).setUp() + super(MobileAPITestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create( mobile_available=True, static_asset_path="needed_for_split", @@ -57,7 +57,7 @@ class MobileAPITestCase(ModuleStoreTestCase, APITestCase): IgnoreMobileAvailableFlagConfig(enabled=False).save() def tearDown(self): - super(MobileAPITestCase, self).tearDown() + super(MobileAPITestCase, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments self.logout() def login(self): diff --git a/lms/djangoapps/mobile_api/users/serializers.py b/lms/djangoapps/mobile_api/users/serializers.py index 8b351b1ee0..b774379975 100644 --- a/lms/djangoapps/mobile_api/users/serializers.py +++ b/lms/djangoapps/mobile_api/users/serializers.py @@ -14,11 +14,11 @@ from common.djangoapps.student.models import CourseEnrollment, User from common.djangoapps.util.course import get_encoded_course_sharing_utm_params, get_link_for_about_page -class CourseOverviewField(serializers.RelatedField): +class CourseOverviewField(serializers.RelatedField): # lint-amnesty, pylint: disable=abstract-method """ Custom field to wrap a CourseOverview object. Read-only. """ - def to_representation(self, course_overview): + def to_representation(self, course_overview): # lint-amnesty, pylint: disable=arguments-differ course_id = six.text_type(course_overview.id) request = self.context.get('request') api_version = self.context.get('api_version') diff --git a/lms/djangoapps/mobile_api/users/tests.py b/lms/djangoapps/mobile_api/users/tests.py index 5430aa1ef5..b7a9073de2 100644 --- a/lms/djangoapps/mobile_api/users/tests.py +++ b/lms/djangoapps/mobile_api/users/tests.py @@ -118,13 +118,13 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest @patch.dict(settings.FEATURES, {"ENABLE_DISCUSSION_SERVICE": True}) def setUp(self): - super(TestUserEnrollmentApi, self).setUp() + super(TestUserEnrollmentApi, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments def verify_success(self, response): """ Verifies user course enrollment response for success """ - super(TestUserEnrollmentApi, self).verify_success(response) + super(TestUserEnrollmentApi, self).verify_success(response) # lint-amnesty, pylint: disable=super-with-arguments courses = response.data self.assertEqual(len(courses), 1) @@ -299,7 +299,7 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest self.create_enrollment(expired) return self.api_response(api_version=api_version).data - def _assert_enrollment_results(self, api_version, courses, num_courses_returned, gating_enabled=True): + def _assert_enrollment_results(self, api_version, courses, num_courses_returned, gating_enabled=True): # lint-amnesty, pylint: disable=missing-function-docstring self.assertEqual(len(courses), num_courses_returned) if api_version == API_V05: @@ -425,7 +425,7 @@ class CourseStatusAPITestCase(MobileAPITestCase): """ Creates a basic course structure for our course """ - super(CourseStatusAPITestCase, self).setUp() + super(CourseStatusAPITestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.section = ItemFactory.create( parent=self.course, @@ -591,7 +591,7 @@ class TestCourseEnrollmentSerializer(MobileAPITestCase, MilestonesTestCaseMixin) ENABLED_SIGNALS = ['course_published'] def setUp(self): - super(TestCourseEnrollmentSerializer, self).setUp() + super(TestCourseEnrollmentSerializer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.login_and_enroll() self.request = RequestFactory().get('/') self.request.user = self.user diff --git a/lms/djangoapps/mobile_api/users/views.py b/lms/djangoapps/mobile_api/users/views.py index 96bea4ec66..7fec2ebc19 100644 --- a/lms/djangoapps/mobile_api/users/views.py +++ b/lms/djangoapps/mobile_api/users/views.py @@ -16,7 +16,7 @@ from rest_framework.decorators import api_view from rest_framework.response import Response from xblock.fields import Scope from xblock.runtime import KeyValueStore -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from lms.djangoapps.courseware.access import is_mobile_available_for_user from lms.djangoapps.courseware.courses import get_current_child @@ -26,7 +26,7 @@ from lms.djangoapps.courseware.views.index import save_positions_recursively_up from lms.djangoapps.courseware.access_utils import ACCESS_GRANTED from lms.djangoapps.mobile_api.utils import API_V05, API_V1 from openedx.features.course_duration_limits.access import check_course_expired -from common.djangoapps.student.models import CourseEnrollment, User +from common.djangoapps.student.models import CourseEnrollment, User # lint-amnesty, pylint: disable=reimported from xmodule.modulestore.django import modulestore from xmodule.modulestore.exceptions import ItemNotFoundError @@ -72,7 +72,7 @@ class UserDetail(generics.RetrieveAPIView): lookup_field = 'username' def get_serializer_context(self): - context = super(UserDetail, self).get_serializer_context() + context = super(UserDetail, self).get_serializer_context() # lint-amnesty, pylint: disable=super-with-arguments context['api_version'] = self.kwargs.get('api_version') return context @@ -188,7 +188,7 @@ class UserCourseStatus(views.APIView): return self._get_course_info(request, course) @mobile_course_access(depth=2) - def get(self, request, course, *args, **kwargs): + def get(self, request, course, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Get the ID of the module that the specified user last visited in the specified course. """ @@ -207,7 +207,7 @@ class UserCourseStatus(views.APIView): return user_course_status @mobile_course_access(depth=2) - def patch(self, request, course, *args, **kwargs): + def patch(self, request, course, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Update the ID of the module that the specified user last visited in the specified course. """ @@ -312,7 +312,7 @@ class UserCourseEnrollmentsList(generics.ListAPIView): return check_org is None or (check_org.lower() == course_org.lower()) def get_serializer_context(self): - context = super(UserCourseEnrollmentsList, self).get_serializer_context() + context = super(UserCourseEnrollmentsList, self).get_serializer_context() # lint-amnesty, pylint: disable=super-with-arguments context['api_version'] = self.kwargs.get('api_version') return context diff --git a/lms/djangoapps/monitoring/__init__.py b/lms/djangoapps/monitoring/__init__.py index 89f1b2b547..f9e3afe6f7 100644 --- a/lms/djangoapps/monitoring/__init__.py +++ b/lms/djangoapps/monitoring/__init__.py @@ -1,3 +1,3 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured LMS specific monitoring helpers. """ From 1f7b33f9bd9426c09face0d6b09c716ef095afdc Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Tue, 2 Feb 2021 11:39:28 +0500 Subject: [PATCH 07/19] BOM-2284 Apply pylint-amnesty. --- lms/djangoapps/mobile_api/__init__.py | 3 ++- lms/djangoapps/monitoring/__init__.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/mobile_api/__init__.py b/lms/djangoapps/mobile_api/__init__.py index d419cba73a..ff3b9b6d27 100644 --- a/lms/djangoapps/mobile_api/__init__.py +++ b/lms/djangoapps/mobile_api/__init__.py @@ -1,3 +1,4 @@ -""" # lint-amnesty, pylint: disable=django-not-configured +""" +# lint-amnesty, pylint: disable=django-not-configured Mobile API """ diff --git a/lms/djangoapps/monitoring/__init__.py b/lms/djangoapps/monitoring/__init__.py index f9e3afe6f7..fe120782d2 100644 --- a/lms/djangoapps/monitoring/__init__.py +++ b/lms/djangoapps/monitoring/__init__.py @@ -1,3 +1,4 @@ -""" # lint-amnesty, pylint: disable=django-not-configured +""" +# lint-amnesty, pylint: disable=django-not-configured LMS specific monitoring helpers. """ From ea26268b0a07f44add8a7d9d11c25d4b82bcdfa4 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Tue, 2 Feb 2021 12:09:42 +0500 Subject: [PATCH 08/19] BOM-2285 Apply pylint-amnesty. --- .../program_enrollments/api/grades.py | 4 ++-- .../program_enrollments/api/reading.py | 6 ++--- .../api/tests/test_reading.py | 2 +- .../api/tests/test_writing.py | 2 +- .../commands/link_program_enrollments.py | 4 ++-- .../tests/test_reset_enrollment_data.py | 2 +- lms/djangoapps/program_enrollments/models.py | 8 +++---- .../rest_api/v1/tests/test_views.py | 22 +++++++++---------- .../program_enrollments/rest_api/v1/views.py | 18 +++++++-------- lms/djangoapps/program_enrollments/signals.py | 2 +- .../program_enrollments/tests/test_admin.py | 2 +- .../program_enrollments/tests/test_models.py | 6 ++--- .../program_enrollments/tests/test_signals.py | 2 +- lms/djangoapps/rss_proxy/tests/test_models.py | 2 +- lms/djangoapps/rss_proxy/tests/test_views.py | 2 +- 15 files changed, 42 insertions(+), 42 deletions(-) diff --git a/lms/djangoapps/program_enrollments/api/grades.py b/lms/djangoapps/program_enrollments/api/grades.py index 00b931bf79..d772b46808 100644 --- a/lms/djangoapps/program_enrollments/api/grades.py +++ b/lms/djangoapps/program_enrollments/api/grades.py @@ -109,7 +109,7 @@ class ProgramCourseGradeOk(BaseProgramCourseGrade): Given a ProgramCourseEnrollment and course grade object, create a ProgramCourseGradeOk. """ - super(ProgramCourseGradeOk, self).__init__( + super(ProgramCourseGradeOk, self).__init__( # lint-amnesty, pylint: disable=super-with-arguments program_course_enrollment ) self.passed = course_grade.passed @@ -129,7 +129,7 @@ class ProgramCourseGradeError(BaseProgramCourseGrade): Given a ProgramCourseEnrollment and an Exception, create a ProgramCourseGradeError. """ - super(ProgramCourseGradeError, self).__init__( + super(ProgramCourseGradeError, self).__init__( # lint-amnesty, pylint: disable=super-with-arguments program_course_enrollment ) self.error = text_type(exception) if exception else "Unknown error" diff --git a/lms/djangoapps/program_enrollments/api/reading.py b/lms/djangoapps/program_enrollments/api/reading.py index 43c61e222f..5a7b6df69a 100644 --- a/lms/djangoapps/program_enrollments/api/reading.py +++ b/lms/djangoapps/program_enrollments/api/reading.py @@ -451,7 +451,7 @@ def get_saml_provider_by_org_key(org_key): try: organization = Organization.objects.get(short_name=org_key) except Organization.DoesNotExist: - raise BadOrganizationShortNameException(org_key) + raise BadOrganizationShortNameException(org_key) # lint-amnesty, pylint: disable=raise-missing-from return get_saml_provider_for_organization(organization) @@ -495,9 +495,9 @@ def get_saml_provider_for_organization(organization): try: provider_config = organization.samlproviderconfig_set.current_set().get(enabled=True) except SAMLProviderConfig.DoesNotExist: - raise ProviderDoesNotExistException(organization) + raise ProviderDoesNotExistException(organization) # lint-amnesty, pylint: disable=raise-missing-from except SAMLProviderConfig.MultipleObjectsReturned: - raise ProviderConfigurationException(organization) + raise ProviderConfigurationException(organization) # lint-amnesty, pylint: disable=raise-missing-from return provider_config diff --git a/lms/djangoapps/program_enrollments/api/tests/test_reading.py b/lms/djangoapps/program_enrollments/api/tests/test_reading.py index 606f3b1568..e0c0ec9add 100644 --- a/lms/djangoapps/program_enrollments/api/tests/test_reading.py +++ b/lms/djangoapps/program_enrollments/api/tests/test_reading.py @@ -504,7 +504,7 @@ class GetUsersByExternalKeysTests(CacheIsolationTestCase): cls.user_2 = UserFactory(username='user-2') def setUp(self): - super(GetUsersByExternalKeysTests, self).setUp() + super(GetUsersByExternalKeysTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments catalog_org = CatalogOrganizationFactory.create(key=self.organization_key) program = ProgramFactory.create( uuid=self.program_uuid, diff --git a/lms/djangoapps/program_enrollments/api/tests/test_writing.py b/lms/djangoapps/program_enrollments/api/tests/test_writing.py index 80841ae978..9dd44a8e2b 100644 --- a/lms/djangoapps/program_enrollments/api/tests/test_writing.py +++ b/lms/djangoapps/program_enrollments/api/tests/test_writing.py @@ -75,7 +75,7 @@ class EnrollmentTestMixin(CacheIsolationTestCase): cls.student_2 = UserFactory(username='student-2') def setUp(self): - super(EnrollmentTestMixin, self).setUp() + super(EnrollmentTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments cache.set(PROGRAM_CACHE_KEY_TPL.format(uuid=self.program_uuid), self.program, None) def create_program_enrollment(self, external_user_key, user=False): diff --git a/lms/djangoapps/program_enrollments/management/commands/link_program_enrollments.py b/lms/djangoapps/program_enrollments/management/commands/link_program_enrollments.py index e202575e17..7f26531008 100644 --- a/lms/djangoapps/program_enrollments/management/commands/link_program_enrollments.py +++ b/lms/djangoapps/program_enrollments/management/commands/link_program_enrollments.py @@ -73,14 +73,14 @@ class Command(BaseCommand): try: parsed_program_uuid = UUID(program_uuid) except ValueError: - raise CommandError("supplied program_uuid '{}' is not a valid UUID") + raise CommandError("supplied program_uuid '{}' is not a valid UUID") # lint-amnesty, pylint: disable=raise-missing-from ext_keys_to_usernames = self.parse_user_items(user_items) try: link_program_enrollments( parsed_program_uuid, ext_keys_to_usernames ) except Exception as e: - raise CommandError(str(e)) + raise CommandError(str(e)) # lint-amnesty, pylint: disable=raise-missing-from def parse_user_items(self, user_items): """ diff --git a/lms/djangoapps/program_enrollments/management/commands/tests/test_reset_enrollment_data.py b/lms/djangoapps/program_enrollments/management/commands/tests/test_reset_enrollment_data.py index 7ba683a6b4..67c45ae4a6 100644 --- a/lms/djangoapps/program_enrollments/management/commands/tests/test_reset_enrollment_data.py +++ b/lms/djangoapps/program_enrollments/management/commands/tests/test_reset_enrollment_data.py @@ -29,7 +29,7 @@ class TestResetEnrollmentData(TestCase): cls.program_uuid = uuid4() def setUp(self): - super(TestResetEnrollmentData, self).setUp() + super(TestResetEnrollmentData, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() @contextmanager diff --git a/lms/djangoapps/program_enrollments/models.py b/lms/djangoapps/program_enrollments/models.py index c990c08431..31deb8a9f7 100644 --- a/lms/djangoapps/program_enrollments/models.py +++ b/lms/djangoapps/program_enrollments/models.py @@ -4,7 +4,7 @@ Django model specifications for the Program Enrollments API """ from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import ValidationError from django.db import models from django.utils.translation import ugettext_lazy as _ @@ -85,7 +85,7 @@ class ProgramEnrollment(TimeStampedModel): return '[ProgramEnrollment id={}]'.format(self.id) def __repr__(self): - return ( + return ( # lint-amnesty, pylint: disable=missing-format-attribute " Date: Tue, 2 Feb 2021 12:39:06 +0500 Subject: [PATCH 09/19] BOM-2286 Apply pylint-amnesty. --- lms/djangoapps/static_template_view/urls.py | 2 +- lms/djangoapps/static_template_view/views.py | 8 +++--- lms/djangoapps/staticbook/tests.py | 2 +- lms/djangoapps/support/tests/test_views.py | 26 +++++++++---------- lms/djangoapps/support/views/contact_us.py | 2 +- lms/djangoapps/support/views/enrollments.py | 4 +-- .../support/views/program_enrollments.py | 4 +-- lms/djangoapps/support/views/sso_records.py | 4 +-- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lms/djangoapps/static_template_view/urls.py b/lms/djangoapps/static_template_view/urls.py index f6a09ef2f5..5dd3fa96be 100644 --- a/lms/djangoapps/static_template_view/urls.py +++ b/lms/djangoapps/static_template_view/urls.py @@ -38,7 +38,7 @@ for key, value in settings.MKTG_URL_LINK_MAP.items(): continue # These urls are enabled separately - if key == "ROOT" or key == "COURSES": + if key == "ROOT" or key == "COURSES": # lint-amnesty, pylint: disable=consider-using-in continue # The MKTG_URL_LINK_MAP key specifies the template filename diff --git a/lms/djangoapps/static_template_view/views.py b/lms/djangoapps/static_template_view/views.py index 76d317d1e9..ffe3a31338 100644 --- a/lms/djangoapps/static_template_view/views.py +++ b/lms/djangoapps/static_template_view/views.py @@ -68,9 +68,9 @@ def render(request, template): result = render_to_response('static_templates/' + template, context, content_type=content_type) return result except TopLevelLookupException: - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from except TemplateDoesNotExist: - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from @ensure_csrf_cookie @@ -87,13 +87,13 @@ def render_press_release(request, slug): try: resp = render_to_response('static_templates/press_releases/' + template, {}) except TemplateDoesNotExist: - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from else: return resp @fix_crum_request -def render_404(request, exception): +def render_404(request, exception): # lint-amnesty, pylint: disable=unused-argument request.view_name = '404' return HttpResponseNotFound(render_to_string('static_templates/404.html', {}, request=request)) diff --git a/lms/djangoapps/staticbook/tests.py b/lms/djangoapps/staticbook/tests.py index 91ed05e3b2..16be937b8e 100644 --- a/lms/djangoapps/staticbook/tests.py +++ b/lms/djangoapps/staticbook/tests.py @@ -50,7 +50,7 @@ class StaticBookTest(ModuleStoreTestCase): """ def __init__(self, *args, **kwargs): - super(StaticBookTest, self).__init__(*args, **kwargs) + super(StaticBookTest, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.course = None def make_course(self, **kwargs): diff --git a/lms/djangoapps/support/tests/test_views.py b/lms/djangoapps/support/tests/test_views.py index 20812ddd13..58dc04daa7 100644 --- a/lms/djangoapps/support/tests/test_views.py +++ b/lms/djangoapps/support/tests/test_views.py @@ -12,7 +12,7 @@ from uuid import UUID, uuid4 import ddt import six -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.db.models import signals from django.http import HttpResponse from django.urls import reverse @@ -29,7 +29,7 @@ from lms.djangoapps.support.serializers import ProgramEnrollmentSerializer from lms.djangoapps.verify_student.models import VerificationDeadline from lms.djangoapps.verify_student.services import IDVerificationService from lms.djangoapps.verify_student.tests.factories import SSOVerificationFactory -from common.djangoapps.student.models import ENROLLED_TO_ENROLLED, CourseEnrollment, CourseEnrollmentAttribute, ManualEnrollmentAudit +from common.djangoapps.student.models import ENROLLED_TO_ENROLLED, CourseEnrollment, CourseEnrollmentAttribute, ManualEnrollmentAudit # lint-amnesty, pylint: disable=line-too-long from common.djangoapps.student.roles import GlobalStaff, SupportStaffRole from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from common.djangoapps.third_party_auth.tests.factories import SAMLProviderConfigFactory @@ -48,7 +48,7 @@ class SupportViewTestCase(ModuleStoreTestCase): def setUp(self): """Create a user and log in. """ - super(SupportViewTestCase, self).setUp() + super(SupportViewTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory(username=self.USERNAME, email=self.EMAIL, password=self.PASSWORD) self.course = CourseFactory.create() success = self.client.login(username=self.USERNAME, password=self.PASSWORD) @@ -62,7 +62,7 @@ class SupportViewManageUserTests(SupportViewTestCase): def setUp(self): """Make the user support staff""" - super(SupportViewManageUserTests, self).setUp() + super(SupportViewManageUserTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments SupportStaffRole().add_users(self.user) def test_get_contact_us(self): @@ -189,7 +189,7 @@ class SupportViewIndexTests(SupportViewTestCase): def setUp(self): """Make the user support staff. """ - super(SupportViewIndexTests, self).setUp() + super(SupportViewIndexTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments SupportStaffRole().add_users(self.user) def test_index(self): @@ -207,7 +207,7 @@ class SupportViewCertificatesTests(SupportViewTestCase): """ def setUp(self): """Make the user support staff. """ - super(SupportViewCertificatesTests, self).setUp() + super(SupportViewCertificatesTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments SupportStaffRole().add_users(self.user) def test_certificates_no_filter(self): @@ -234,7 +234,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase """Tests for the enrollment support view.""" def setUp(self): - super(SupportViewEnrollmentsTests, self).setUp() + super(SupportViewEnrollmentsTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments SupportStaffRole().add_users(self.user) self.course = CourseFactory(display_name=u'teꜱᴛ') @@ -477,7 +477,7 @@ class SupportViewLinkProgramEnrollmentsTests(SupportViewTestCase): def setUp(self): """Make the user support staff. """ - super(SupportViewLinkProgramEnrollmentsTests, self).setUp() + super(SupportViewLinkProgramEnrollmentsTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse("support:link_program_enrollments") SupportStaffRole().add_users(self.user) self.program_uuid = str(uuid4()) @@ -645,7 +645,7 @@ class ProgramEnrollmentsInspectorViewTests(SupportViewTestCase): ) def setUp(self): - super(ProgramEnrollmentsInspectorViewTests, self).setUp() + super(ProgramEnrollmentsInspectorViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse("support:program_enrollments_inspector") SupportStaffRole().add_users(self.user) self.program_uuid = str(uuid4()) @@ -725,7 +725,7 @@ class ProgramEnrollmentsInspectorViewTests(SupportViewTestCase): is_active=True ) - program_course_enrollment = ProgramCourseEnrollmentFactory.create( + program_course_enrollment = ProgramCourseEnrollmentFactory.create( # lint-amnesty, pylint: disable=unused-variable program_enrollment=program_enrollment, course_key=course_id, course_enrollment=course_enrollment, @@ -962,11 +962,11 @@ class ProgramEnrollmentsInspectorViewTests(SupportViewTestCase): assert expected_error == render_call_dict['error'] -class SsoRecordsTests(SupportViewTestCase): +class SsoRecordsTests(SupportViewTestCase): # lint-amnesty, pylint: disable=missing-class-docstring def setUp(self): """Make the user support staff""" - super(SsoRecordsTests, self).setUp() + super(SsoRecordsTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments SupportStaffRole().add_users(self.user) self.student = UserFactory.create(username='student', email='test@example.com', password='test') self.url = reverse("support:sso_records", kwargs={'username_or_email': self.student.username}) @@ -994,7 +994,7 @@ class SsoRecordsTests(SupportViewTestCase): self.assertEqual(len(data), 0) def test_response(self): - user_social_auth = UserSocialAuth.objects.create( + user_social_auth = UserSocialAuth.objects.create( # lint-amnesty, pylint: disable=unused-variable user=self.student, uid=self.student.email, provider='tpa-saml' diff --git a/lms/djangoapps/support/views/contact_us.py b/lms/djangoapps/support/views/contact_us.py index 8401546df8..4612ef4667 100644 --- a/lms/djangoapps/support/views/contact_us.py +++ b/lms/djangoapps/support/views/contact_us.py @@ -18,7 +18,7 @@ class ContactUsView(View): View for viewing and submitting contact us form. """ - def get(self, request): + def get(self, request): # lint-amnesty, pylint: disable=missing-function-docstring if not configuration_helpers.get_value('CONTACT_US_PAGE', True): raise Http404 diff --git a/lms/djangoapps/support/views/enrollments.py b/lms/djangoapps/support/views/enrollments.py index b505af2655..4a3c43039b 100644 --- a/lms/djangoapps/support/views/enrollments.py +++ b/lms/djangoapps/support/views/enrollments.py @@ -4,7 +4,7 @@ Support tool for changing course enrollments. import six -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.db import transaction from django.db.models import Q from django.http import HttpResponseBadRequest @@ -25,7 +25,7 @@ from openedx.core.djangoapps.credit.email_utils import get_credit_provider_attri from openedx.core.djangoapps.enrollments.api import get_enrollments, update_enrollment from openedx.core.djangoapps.enrollments.errors import CourseModeNotFoundError from openedx.core.djangoapps.enrollments.serializers import ModeSerializer -from common.djangoapps.student.models import ENROLLED_TO_ENROLLED, CourseEnrollment, CourseEnrollmentAttribute, ManualEnrollmentAudit +from common.djangoapps.student.models import ENROLLED_TO_ENROLLED, CourseEnrollment, CourseEnrollmentAttribute, ManualEnrollmentAudit # lint-amnesty, pylint: disable=line-too-long from common.djangoapps.util.json_request import JsonResponse diff --git a/lms/djangoapps/support/views/program_enrollments.py b/lms/djangoapps/support/views/program_enrollments.py index 80d2c83359..c0454abc99 100644 --- a/lms/djangoapps/support/views/program_enrollments.py +++ b/lms/djangoapps/support/views/program_enrollments.py @@ -6,7 +6,7 @@ Support tool for changing course enrollments. import csv from uuid import UUID -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.db.models import Q from django.utils.decorators import method_decorator from django.views.generic import View @@ -115,7 +115,7 @@ class LinkProgramEnrollmentSupportView(View): for item in ext_key_to_username.items() if item not in link_errors ] - errors = [message for message in link_errors.values()] + errors = [message for message in link_errors.values()] # lint-amnesty, pylint: disable=unnecessary-comprehension return successes, errors diff --git a/lms/djangoapps/support/views/sso_records.py b/lms/djangoapps/support/views/sso_records.py index 32e620be2c..455101baa3 100644 --- a/lms/djangoapps/support/views/sso_records.py +++ b/lms/djangoapps/support/views/sso_records.py @@ -1,4 +1,4 @@ -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user, missing-module-docstring from django.db.models import Q from django.utils.decorators import method_decorator from rest_framework.generics import GenericAPIView @@ -14,7 +14,7 @@ class SsoView(GenericAPIView): Returns a list of SSO records for a given user. """ @method_decorator(require_support_permission) - def get(self, request, username_or_email): + def get(self, request, username_or_email): # lint-amnesty, pylint: disable=missing-function-docstring try: user = User.objects.get(Q(username=username_or_email) | Q(email=username_or_email)) except User.DoesNotExist: From 08f3ea6852271f8c40313244590d25f2701bd79c Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Tue, 2 Feb 2021 13:29:06 +0500 Subject: [PATCH 10/19] BOM-2286 Apply pylint-amnesty. --- lms/djangoapps/support/views/sso_records.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/support/views/sso_records.py b/lms/djangoapps/support/views/sso_records.py index 455101baa3..00be03e6db 100644 --- a/lms/djangoapps/support/views/sso_records.py +++ b/lms/djangoapps/support/views/sso_records.py @@ -1,4 +1,8 @@ -from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user, missing-module-docstring +""" +Views for SSO records. +""" + +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.db.models import Q from django.utils.decorators import method_decorator from rest_framework.generics import GenericAPIView From 3ce03896af08c781406a36569d8c80a686fbc7f8 Mon Sep 17 00:00:00 2001 From: Jawayria Date: Tue, 2 Feb 2021 13:38:45 +0500 Subject: [PATCH 11/19] Applied pylint-amnesty to status --- common/djangoapps/status/models.py | 4 ++-- common/djangoapps/status/tests.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/djangoapps/status/models.py b/common/djangoapps/status/models.py index e48af5394c..5f4634c6f9 100644 --- a/common/djangoapps/status/models.py +++ b/common/djangoapps/status/models.py @@ -26,9 +26,9 @@ class GlobalStatusMessage(ConfigurationModel): blank=True, null=True, help_text=u'

    The contents of this field will be displayed as a warning banner on all views.

    ' - u'

    To override the banner message for a specific course, refer to the Course Message configuration. ' + u'

    To override the banner message for a specific course, refer to the Course Message configuration. ' # lint-amnesty, pylint: disable=line-too-long u'Course Messages will only work if the global status message is enabled, so if you only want to add ' - u'a banner to specific courses without adding a global status message, you should add a global status ' + u'a banner to specific courses without adding a global status message, you should add a global status ' # lint-amnesty, pylint: disable=line-too-long u'message with empty message text.

    ' u'

    Finally, disable the global status message by adding another empty message with "enabled" ' u'unchecked.

    ') diff --git a/common/djangoapps/status/tests.py b/common/djangoapps/status/tests.py index 5c21f03f5d..a365344b0b 100644 --- a/common/djangoapps/status/tests.py +++ b/common/djangoapps/status/tests.py @@ -21,7 +21,7 @@ class TestStatus(TestCase): """Test that the get_site_status_msg function does the right thing""" def setUp(self): - super(TestStatus, self).setUp() + super(TestStatus, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Clear the cache between test runs. cache.clear() self.course_key = CourseLocator(org='TestOrg', course='TestCourse', run='TestRun') From fb6a62b753f956b05738ad4bb6f7d669176ee988 Mon Sep 17 00:00:00 2001 From: Jawayria Date: Tue, 2 Feb 2021 14:37:08 +0500 Subject: [PATCH 12/19] Applied pylint-amnesty to terrain --- common/djangoapps/terrain/stubs/catalog.py | 4 ++-- common/djangoapps/terrain/stubs/comments.py | 20 +++++++++---------- common/djangoapps/terrain/stubs/edxnotes.py | 4 ++-- common/djangoapps/terrain/stubs/http.py | 2 +- common/djangoapps/terrain/stubs/start.py | 2 +- .../terrain/stubs/tests/test_edxnotes.py | 2 +- .../terrain/stubs/tests/test_http.py | 8 ++++---- .../terrain/stubs/tests/test_lti_stub.py | 4 ++-- .../terrain/stubs/tests/test_video.py | 2 +- .../terrain/stubs/tests/test_xqueue_stub.py | 8 ++++---- .../terrain/stubs/tests/test_youtube_stub.py | 4 ++-- common/djangoapps/terrain/stubs/youtube.py | 2 +- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/common/djangoapps/terrain/stubs/catalog.py b/common/djangoapps/terrain/stubs/catalog.py index d2cdebe5dc..1767485028 100644 --- a/common/djangoapps/terrain/stubs/catalog.py +++ b/common/djangoapps/terrain/stubs/catalog.py @@ -11,9 +11,9 @@ import six.moves.urllib.parse from .http import StubHttpRequestHandler, StubHttpService -class StubCatalogServiceHandler(StubHttpRequestHandler): +class StubCatalogServiceHandler(StubHttpRequestHandler): # lint-amnesty, pylint: disable=missing-class-docstring - def do_GET(self): + def do_GET(self): # lint-amnesty, pylint: disable=missing-function-docstring pattern_handlers = { r'/api/v1/programs/$': self.program_list, r'/api/v1/programs/([0-9a-f-]+)/$': self.program_detail, diff --git a/common/djangoapps/terrain/stubs/comments.py b/common/djangoapps/terrain/stubs/comments.py index 4d46e0081c..8fef4b33e3 100644 --- a/common/djangoapps/terrain/stubs/comments.py +++ b/common/djangoapps/terrain/stubs/comments.py @@ -11,13 +11,13 @@ import six.moves.urllib.parse from .http import StubHttpRequestHandler, StubHttpService -class StubCommentsServiceHandler(StubHttpRequestHandler): +class StubCommentsServiceHandler(StubHttpRequestHandler): # lint-amnesty, pylint: disable=missing-class-docstring @property def _params(self): return six.moves.urllib.parse.parse_qs(six.moves.urllib.parse.urlparse(self.path).query) - def do_GET(self): + def do_GET(self): # lint-amnesty, pylint: disable=missing-function-docstring pattern_handlers = OrderedDict([ ("/api/v1/users/(?P\\d+)/active_threads$", self.do_user_profile), ("/api/v1/users/(?P\\d+)$", self.do_user), @@ -32,7 +32,7 @@ class StubCommentsServiceHandler(StubHttpRequestHandler): self.send_response(404, content="404 Not Found") - def match_pattern(self, pattern_handlers): + def match_pattern(self, pattern_handlers): # lint-amnesty, pylint: disable=missing-function-docstring path = six.moves.urllib.parse.urlparse(self.path).path for pattern in pattern_handlers: match = re.match(pattern, path) @@ -51,11 +51,11 @@ class StubCommentsServiceHandler(StubHttpRequestHandler): return self.send_response(204, "") - def do_put_user(self, user_id): + def do_put_user(self, user_id): # lint-amnesty, pylint: disable=unused-argument self.server.config['default_sort_key'] = self.post_dict.get("default_sort_key", "date") - self.send_json_response({'username': self.post_dict.get("username"), 'external_id': self.post_dict.get("external_id")}) + self.send_json_response({'username': self.post_dict.get("username"), 'external_id': self.post_dict.get("external_id")}) # lint-amnesty, pylint: disable=line-too-long - def do_DELETE(self): + def do_DELETE(self): # lint-amnesty, pylint: disable=missing-function-docstring pattern_handlers = { "/api/v1/comments/(?P\\w+)$": self.do_delete_comment } @@ -63,7 +63,7 @@ class StubCommentsServiceHandler(StubHttpRequestHandler): return self.send_json_response({}) - def do_user(self, user_id): + def do_user(self, user_id): # lint-amnesty, pylint: disable=missing-function-docstring response = { "id": user_id, "default_sort_key": self.server.config.get("default_sort_key", "date"), @@ -78,7 +78,7 @@ class StubCommentsServiceHandler(StubHttpRequestHandler): }) self.send_json_response(response) - def do_user_profile(self, user_id): + def do_user_profile(self, user_id): # lint-amnesty, pylint: disable=missing-function-docstring, unused-argument if 'active_threads' in self.server.config: user_threads = self.server.config['active_threads'][:] params = self._params @@ -94,13 +94,13 @@ class StubCommentsServiceHandler(StubHttpRequestHandler): else: self.send_response(404, content="404 Not Found") - def do_thread(self, thread_id): + def do_thread(self, thread_id): # lint-amnesty, pylint: disable=missing-function-docstring if thread_id in self.server.config.get('threads', {}): thread = self.server.config['threads'][thread_id].copy() params = six.moves.urllib.parse.parse_qs(six.moves.urllib.parse.urlparse(self.path).query) if "recursive" in params and params["recursive"][0] == "True": thread.setdefault('children', []) - resp_total = thread.setdefault('resp_total', len(thread['children'])) + resp_total = thread.setdefault('resp_total', len(thread['children'])) # lint-amnesty, pylint: disable=unused-variable resp_skip = int(params.get("resp_skip", ["0"])[0]) resp_limit = int(params.get("resp_limit", ["10000"])[0]) thread['children'] = thread['children'][resp_skip:(resp_skip + resp_limit)] diff --git a/common/djangoapps/terrain/stubs/edxnotes.py b/common/djangoapps/terrain/stubs/edxnotes.py index 9d1b83697a..458dea52ad 100644 --- a/common/djangoapps/terrain/stubs/edxnotes.py +++ b/common/djangoapps/terrain/stubs/edxnotes.py @@ -107,7 +107,7 @@ class StubEdxNotesServiceHandler(StubHttpRequestHandler): self.send_response(200, headers={ "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS", - "Access-Control-Allow-Headers": "Content-Length, Content-Type, X-Annotator-Auth-Token, X-Requested-With, X-Annotator-Auth-Token, X-Requested-With, X-CSRFToken", + "Access-Control-Allow-Headers": "Content-Length, Content-Type, X-Annotator-Auth-Token, X-Requested-With, X-Annotator-Auth-Token, X-Requested-With, X-CSRFToken", # lint-amnesty, pylint: disable=line-too-long }) def respond(self, status_code=200, content=None): @@ -300,7 +300,7 @@ class StubEdxNotesService(StubHttpService): HANDLER_CLASS = StubEdxNotesServiceHandler def __init__(self, *args, **kwargs): - super(StubEdxNotesService, self).__init__(*args, **kwargs) + super(StubEdxNotesService, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.notes = list() def get_all_notes(self): diff --git a/common/djangoapps/terrain/stubs/http.py b/common/djangoapps/terrain/stubs/http.py index 7cf277b89f..978f5e2726 100644 --- a/common/djangoapps/terrain/stubs/http.py +++ b/common/djangoapps/terrain/stubs/http.py @@ -117,7 +117,7 @@ class StubHttpRequestHandler(BaseHTTPRequestHandler, object): for key, list_val in post_dict.items() } - except: + except: # lint-amnesty, pylint: disable=bare-except return dict() @lazy diff --git a/common/djangoapps/terrain/stubs/start.py b/common/djangoapps/terrain/stubs/start.py index 6b05cdc665..c9ea349e46 100644 --- a/common/djangoapps/terrain/stubs/start.py +++ b/common/djangoapps/terrain/stubs/start.py @@ -78,7 +78,7 @@ def _parse_config_args(args): if len(components) >= 2: config_dict[components[0]] = "=".join(components[1:]) - except: + except: # lint-amnesty, pylint: disable=bare-except print("Warning: could not interpret config value '{0}'".format(config_str)) return config_dict diff --git a/common/djangoapps/terrain/stubs/tests/test_edxnotes.py b/common/djangoapps/terrain/stubs/tests/test_edxnotes.py index 340038b609..adef731833 100644 --- a/common/djangoapps/terrain/stubs/tests/test_edxnotes.py +++ b/common/djangoapps/terrain/stubs/tests/test_edxnotes.py @@ -24,7 +24,7 @@ class StubEdxNotesServiceTest(unittest.TestCase): """ Start the stub server. """ - super(StubEdxNotesServiceTest, self).setUp() + super(StubEdxNotesServiceTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.server = StubEdxNotesService() dummy_notes = self._get_dummy_notes(count=5) self.server.add_notes(dummy_notes) diff --git a/common/djangoapps/terrain/stubs/tests/test_http.py b/common/djangoapps/terrain/stubs/tests/test_http.py index 75a913c984..b88f9c7ec9 100644 --- a/common/djangoapps/terrain/stubs/tests/test_http.py +++ b/common/djangoapps/terrain/stubs/tests/test_http.py @@ -12,10 +12,10 @@ import six from common.djangoapps.terrain.stubs.http import StubHttpRequestHandler, StubHttpService, require_params -class StubHttpServiceTest(unittest.TestCase): +class StubHttpServiceTest(unittest.TestCase): # lint-amnesty, pylint: disable=missing-class-docstring def setUp(self): - super(StubHttpServiceTest, self).setUp() + super(StubHttpServiceTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.server = StubHttpService() self.addCleanup(self.server.shutdown) self.url = "http://127.0.0.1:{0}/set_config".format(self.server.port) @@ -71,7 +71,7 @@ class StubHttpServiceTest(unittest.TestCase): self.assertEqual(response.status_code, 404) -class RequireRequestHandler(StubHttpRequestHandler): +class RequireRequestHandler(StubHttpRequestHandler): # lint-amnesty, pylint: disable=missing-class-docstring @require_params('GET', 'test_param') def do_GET(self): self.send_response(200) @@ -91,7 +91,7 @@ class RequireParamTest(unittest.TestCase): """ def setUp(self): - super(RequireParamTest, self).setUp() + super(RequireParamTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.server = RequireHttpService() self.addCleanup(self.server.shutdown) self.url = "http://127.0.0.1:{port}".format(port=self.server.port) diff --git a/common/djangoapps/terrain/stubs/tests/test_lti_stub.py b/common/djangoapps/terrain/stubs/tests/test_lti_stub.py index 501a2dec83..ba1775f1b0 100644 --- a/common/djangoapps/terrain/stubs/tests/test_lti_stub.py +++ b/common/djangoapps/terrain/stubs/tests/test_lti_stub.py @@ -20,7 +20,7 @@ class StubLtiServiceTest(unittest.TestCase): Used for lettuce BDD tests in lms/courseware/features/lti.feature """ def setUp(self): - super(StubLtiServiceTest, self).setUp() + super(StubLtiServiceTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.server = StubLtiService() self.uri = 'http://127.0.0.1:{}/'.format(self.server.port) self.launch_uri = self.uri + 'correct_lti_endpoint' @@ -60,7 +60,7 @@ class StubLtiServiceTest(unittest.TestCase): self.assertIn(b'Wrong LTI signature', response.content) @patch('common.djangoapps.terrain.stubs.lti.signature.verify_hmac_sha1', return_value=True) - def test_success_response_launch_lti(self, check_oauth): + def test_success_response_launch_lti(self, check_oauth): # lint-amnesty, pylint: disable=unused-argument """ Success lti launch. """ diff --git a/common/djangoapps/terrain/stubs/tests/test_video.py b/common/djangoapps/terrain/stubs/tests/test_video.py index f6da4da2b3..edfe33c697 100644 --- a/common/djangoapps/terrain/stubs/tests/test_video.py +++ b/common/djangoapps/terrain/stubs/tests/test_video.py @@ -33,7 +33,7 @@ class StubVideoServiceTest(unittest.TestCase): """ Start the stub server. """ - super(StubVideoServiceTest, self).setUp() + super(StubVideoServiceTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.server = VideoSourceHttpService() self.server.config['root_dir'] = '{}/data/video'.format(settings.TEST_ROOT) self.addCleanup(self.server.shutdown) diff --git a/common/djangoapps/terrain/stubs/tests/test_xqueue_stub.py b/common/djangoapps/terrain/stubs/tests/test_xqueue_stub.py index b60180275f..2f36a9d6dd 100644 --- a/common/djangoapps/terrain/stubs/tests/test_xqueue_stub.py +++ b/common/djangoapps/terrain/stubs/tests/test_xqueue_stub.py @@ -17,17 +17,17 @@ class FakeTimer(object): """ Fake timer implementation that executes immediately. """ - def __init__(self, delay, func): + def __init__(self, delay, func): # lint-amnesty, pylint: disable=unused-argument self.func = func def start(self): self.func() -class StubXQueueServiceTest(unittest.TestCase): +class StubXQueueServiceTest(unittest.TestCase): # lint-amnesty, pylint: disable=missing-class-docstring def setUp(self): - super(StubXQueueServiceTest, self).setUp() + super(StubXQueueServiceTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.server = StubXQueueService() self.url = "http://127.0.0.1:{0}/xqueue/submit".format(self.server.port) self.addCleanup(self.server.shutdown) @@ -119,7 +119,7 @@ class StubXQueueServiceTest(unittest.TestCase): self.assertFalse(self.post.called) self.assertTrue(logger.error.called) - def _post_submission(self, callback_url, lms_key, queue_name, xqueue_body): + def _post_submission(self, callback_url, lms_key, queue_name, xqueue_body): # lint-amnesty, pylint: disable=unused-argument """ Post a submission to the stub XQueue implementation. `callback_url` is the URL at which we expect to receive a grade response diff --git a/common/djangoapps/terrain/stubs/tests/test_youtube_stub.py b/common/djangoapps/terrain/stubs/tests/test_youtube_stub.py index 713b8ad351..a1fe1d8329 100644 --- a/common/djangoapps/terrain/stubs/tests/test_youtube_stub.py +++ b/common/djangoapps/terrain/stubs/tests/test_youtube_stub.py @@ -10,10 +10,10 @@ import requests from ..youtube import StubYouTubeService -class StubYouTubeServiceTest(unittest.TestCase): +class StubYouTubeServiceTest(unittest.TestCase): # lint-amnesty, pylint: disable=missing-class-docstring def setUp(self): - super(StubYouTubeServiceTest, self).setUp() + super(StubYouTubeServiceTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.server = StubYouTubeService() self.url = "http://127.0.0.1:{0}/".format(self.server.port) self.server.config['time_to_response'] = 0.0 diff --git a/common/djangoapps/terrain/stubs/youtube.py b/common/djangoapps/terrain/stubs/youtube.py index ff7e474048..64b79c216b 100644 --- a/common/djangoapps/terrain/stubs/youtube.py +++ b/common/djangoapps/terrain/stubs/youtube.py @@ -91,7 +91,7 @@ class StubYouTubeHandler(StubHttpRequestHandler): youtube_id = params.path.split('/').pop() if self.server.config.get('youtube_api_private_video'): - self._send_private_video_response(youtube_id, "I'm youtube private video.") + self._send_private_video_response(youtube_id, "I'm youtube private video.") # lint-amnesty, pylint: disable=too-many-function-args else: self._send_video_response(youtube_id, "I'm youtube.") From f3846144a5734a375e265fb219fc4a0f10a1ec96 Mon Sep 17 00:00:00 2001 From: Jawayria Date: Tue, 2 Feb 2021 15:09:08 +0500 Subject: [PATCH 13/19] Applied pylint-amnesty to xblock_django --- common/djangoapps/xblock_django/admin.py | 2 +- common/djangoapps/xblock_django/tests/test_api.py | 4 ++-- common/djangoapps/xblock_django/tests/test_user_service.py | 2 +- common/djangoapps/xblock_django/user_service.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/djangoapps/xblock_django/admin.py b/common/djangoapps/xblock_django/admin.py index 21a8950b75..f57e3a894d 100644 --- a/common/djangoapps/xblock_django/admin.py +++ b/common/djangoapps/xblock_django/admin.py @@ -7,7 +7,7 @@ from config_models.admin import ConfigurationModelAdmin, KeyedConfigurationModel from django.contrib import admin from django.utils.translation import ugettext_lazy as _ -from common.djangoapps.xblock_django.models import XBlockConfiguration, XBlockStudioConfiguration, XBlockStudioConfigurationFlag +from common.djangoapps.xblock_django.models import XBlockConfiguration, XBlockStudioConfiguration, XBlockStudioConfigurationFlag # lint-amnesty, pylint: disable=line-too-long class XBlockConfigurationAdmin(KeyedConfigurationModelAdmin): diff --git a/common/djangoapps/xblock_django/tests/test_api.py b/common/djangoapps/xblock_django/tests/test_api.py index 68499af1c0..cffb70be41 100644 --- a/common/djangoapps/xblock_django/tests/test_api.py +++ b/common/djangoapps/xblock_django/tests/test_api.py @@ -7,7 +7,7 @@ import six from openedx.core.djangolib.testing.utils import CacheIsolationTestCase from common.djangoapps.xblock_django.api import authorable_xblocks, deprecated_xblocks, disabled_xblocks -from common.djangoapps.xblock_django.models import XBlockConfiguration, XBlockStudioConfiguration, XBlockStudioConfigurationFlag +from common.djangoapps.xblock_django.models import XBlockConfiguration, XBlockStudioConfiguration, XBlockStudioConfigurationFlag # lint-amnesty, pylint: disable=line-too-long class XBlockSupportTestCase(CacheIsolationTestCase): @@ -15,7 +15,7 @@ class XBlockSupportTestCase(CacheIsolationTestCase): Tests for XBlock Support methods. """ def setUp(self): - super(XBlockSupportTestCase, self).setUp() + super(XBlockSupportTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Set up XBlockConfigurations for disabled and deprecated states block_config = [ diff --git a/common/djangoapps/xblock_django/tests/test_user_service.py b/common/djangoapps/xblock_django/tests/test_user_service.py index c47e10f7c9..ff6d148673 100644 --- a/common/djangoapps/xblock_django/tests/test_user_service.py +++ b/common/djangoapps/xblock_django/tests/test_user_service.py @@ -26,7 +26,7 @@ class UserServiceTestCase(TestCase): Tests for the DjangoXBlockUserService. """ def setUp(self): - super(UserServiceTestCase, self).setUp() + super(UserServiceTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory(username="tester", email="test@tester.com") self.user.profile.name = "Test Tester" set_user_preference(self.user, 'pref-lang', 'en') diff --git a/common/djangoapps/xblock_django/user_service.py b/common/djangoapps/xblock_django/user_service.py index be41454b8f..bd341089a5 100644 --- a/common/djangoapps/xblock_django/user_service.py +++ b/common/djangoapps/xblock_django/user_service.py @@ -3,7 +3,7 @@ Support for converting a django user to an XBlock user """ -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 xblock.reference.user_service import UserService, XBlockUser @@ -24,7 +24,7 @@ class DjangoXBlockUserService(UserService): A user service that converts Django users to XBlockUser """ def __init__(self, django_user, **kwargs): - super(DjangoXBlockUserService, self).__init__(**kwargs) + super(DjangoXBlockUserService, self).__init__(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments self._django_user = django_user if self._django_user: self._django_user.user_is_staff = kwargs.get('user_is_staff', False) From 8556d670a27ed0ba2713aa31bb7bcef27497b93f Mon Sep 17 00:00:00 2001 From: usamasadiq Date: Tue, 2 Feb 2021 15:29:41 +0500 Subject: [PATCH 14/19] Applied pylint-amnesty --- cms/__init__.py | 2 +- cms/celery.py | 2 +- cms/conftest.py | 2 +- cms/envs/devstack.py | 4 ++-- cms/envs/devstack_decentralized.py | 2 +- cms/envs/devstack_optimized.py | 2 +- cms/envs/devstack_with_worker.py | 2 +- cms/envs/production.py | 8 ++++---- cms/envs/test.py | 2 +- cms/lib/xblock/field_data.py | 2 +- cms/lib/xblock/tagging/tagging.py | 2 +- cms/lib/xblock/tagging/test.py | 8 ++++---- cms/lib/xblock/test/test_authoring_mixin.py | 6 +++--- cms/lib/xblock/test/test_runtime.py | 2 +- cms/wsgi.py | 8 ++++---- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/cms/__init__.py b/cms/__init__.py index e022c752ac..f9ed0bb3ce 100644 --- a/cms/__init__.py +++ b/cms/__init__.py @@ -21,4 +21,4 @@ kombu.utils.entrypoints = lambda namespace: iter([]) # This will make sure the app is always imported when Django starts so # that shared_task will use this app, and also ensures that the celery # singleton is always configured for the CMS. -from .celery import APP as CELERY_APP +from .celery import APP as CELERY_APP # lint-amnesty, pylint: disable=wrong-import-position diff --git a/cms/celery.py b/cms/celery.py index 293121bcf2..15d1e0beb0 100644 --- a/cms/celery.py +++ b/cms/celery.py @@ -1,4 +1,4 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured Import celery, load its settings from the django settings and auto discover tasks in all installed django apps. diff --git a/cms/conftest.py b/cms/conftest.py index f66b4c4f54..ca29e3fb5f 100644 --- a/cms/conftest.py +++ b/cms/conftest.py @@ -53,7 +53,7 @@ def _django_clear_site_cache(): clearing mechanism actually works. So override this fixture to not mess with what has been working for us so far. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass @pytest.fixture(autouse=True) diff --git a/cms/envs/devstack.py b/cms/envs/devstack.py index cf538ec1a7..5e371e6315 100644 --- a/cms/envs/devstack.py +++ b/cms/envs/devstack.py @@ -107,7 +107,7 @@ DEBUG_TOOLBAR_CONFIG = { } -def should_show_debug_toolbar(request): +def should_show_debug_toolbar(request): # lint-amnesty, pylint: disable=missing-function-docstring # We always want the toolbar on devstack unless running tests from another Docker container hostname = request.get_host() if hostname.startswith('edx.devstack.studio:') or hostname.startswith('studio.devstack.edx:'): @@ -195,7 +195,7 @@ JWT_AUTH.update({ ), }) -# pylint: enable=unicode-format-string +# pylint: enable=unicode-format-string # lint-amnesty, pylint: disable=bad-option-value IDA_LOGOUT_URI_LIST = [ 'http://localhost:18130/logout/', # ecommerce diff --git a/cms/envs/devstack_decentralized.py b/cms/envs/devstack_decentralized.py index 40f1d01799..48c8937a4e 100644 --- a/cms/envs/devstack_decentralized.py +++ b/cms/envs/devstack_decentralized.py @@ -150,7 +150,7 @@ JWT_AUTH.update({ ), }) -# pylint: enable=unicode-format-string +# pylint: enable=unicode-format-string # lint-amnesty, pylint: disable=bad-option-value IDA_LOGOUT_URI_LIST = [ 'http://localhost:18130/logout/', # ecommerce diff --git a/cms/envs/devstack_optimized.py b/cms/envs/devstack_optimized.py index d869e53620..d81ef1502f 100644 --- a/cms/envs/devstack_optimized.py +++ b/cms/envs/devstack_optimized.py @@ -19,7 +19,7 @@ invoked each time that changes have been made. """ -import os +import os # lint-amnesty, pylint: disable=unused-import ########################## Devstack settings ################################### diff --git a/cms/envs/devstack_with_worker.py b/cms/envs/devstack_with_worker.py index 1265492b71..193c2a8075 100644 --- a/cms/envs/devstack_with_worker.py +++ b/cms/envs/devstack_with_worker.py @@ -12,7 +12,7 @@ In two separate processes on devstack: """ -import os +import os # lint-amnesty, pylint: disable=unused-import # We intentionally define lots of variables that aren't used, and # want to import all variables from base settings files diff --git a/cms/envs/production.py b/cms/envs/production.py index c07b0c9ddd..818395b707 100644 --- a/cms/envs/production.py +++ b/cms/envs/production.py @@ -22,9 +22,9 @@ from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType from .common import * -from openedx.core.lib.derived import derive_settings -from openedx.core.lib.logsettings import get_logger_config -from xmodule.modulestore.modulestore_settings import convert_module_store_setting_if_needed +from openedx.core.lib.derived import derive_settings # lint-amnesty, pylint: disable=wrong-import-order +from openedx.core.lib.logsettings import get_logger_config # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.modulestore_settings import convert_module_store_setting_if_needed # lint-amnesty, pylint: disable=wrong-import-order def get_env_setting(setting): @@ -33,7 +33,7 @@ def get_env_setting(setting): return os.environ[setting] except KeyError: error_msg = u"Set the %s env variable" % setting - raise ImproperlyConfigured(error_msg) + raise ImproperlyConfigured(error_msg) # lint-amnesty, pylint: disable=raise-missing-from ############### ALWAYS THE SAME ################################ diff --git a/cms/envs/test.py b/cms/envs/test.py index 5cc0f0f005..9d99251684 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -75,7 +75,7 @@ COMMON_TEST_DATA_ROOT = COMMON_ROOT / "test" / "data" FEATURES['ENABLE_EXPORT_GIT'] = True GIT_REPO_EXPORT_DIR = TEST_ROOT / "export_course_repos" -# TODO (cpennington): We need to figure out how envs/test.py can inject things into common.py so that we don't have to repeat this sort of thing +# TODO (cpennington): We need to figure out how envs/test.py can inject things into common.py so that we don't have to repeat this sort of thing # lint-amnesty, pylint: disable=line-too-long STATICFILES_DIRS = [ COMMON_ROOT / "static", PROJECT_ROOT / "static", diff --git a/cms/lib/xblock/field_data.py b/cms/lib/xblock/field_data.py index dc687e257e..d00425d613 100644 --- a/cms/lib/xblock/field_data.py +++ b/cms/lib/xblock/field_data.py @@ -21,7 +21,7 @@ class CmsFieldData(SplitFieldData): self._authored_data = authored_data self._student_data = student_data - super(CmsFieldData, self).__init__({ + super(CmsFieldData, self).__init__({ # lint-amnesty, pylint: disable=super-with-arguments Scope.content: authored_data, Scope.settings: authored_data, Scope.parent: authored_data, diff --git a/cms/lib/xblock/tagging/tagging.py b/cms/lib/xblock/tagging/tagging.py index 067e4ac510..d5da37ee7d 100644 --- a/cms/lib/xblock/tagging/tagging.py +++ b/cms/lib/xblock/tagging/tagging.py @@ -77,7 +77,7 @@ class StructuredTagsAside(XBlockAside): return Fragment(u'') @XBlock.handler - def save_tags(self, request=None, suffix=None): + def save_tags(self, request=None, suffix=None): # lint-amnesty, pylint: disable=unused-argument """ Handler to save choosen tags with connected XBlock """ diff --git a/cms/lib/xblock/tagging/test.py b/cms/lib/xblock/tagging/test.py index 41e8277dc7..685b0440eb 100644 --- a/cms/lib/xblock/tagging/test.py +++ b/cms/lib/xblock/tagging/test.py @@ -39,7 +39,7 @@ class StructuredTagsAsideTestCase(ModuleStoreTestCase): """ Preparation for the test execution """ - super(StructuredTagsAsideTestCase, self).setUp() + super(StructuredTagsAsideTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.aside_name = 'tagging_aside' self.aside_tag_dif = 'difficulty' self.aside_tag_dif_value = 'Hard' @@ -113,7 +113,7 @@ class StructuredTagsAsideTestCase(ModuleStoreTestCase): def tearDown(self): TagAvailableValues.objects.all().delete() TagCategories.objects.all().delete() - super(StructuredTagsAsideTestCase, self).tearDown() + super(StructuredTagsAsideTestCase, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments def test_aside_contains_tags(self): """ @@ -181,11 +181,11 @@ class StructuredTagsAsideTestCase(ModuleStoreTestCase): self.assertEqual(option_values2, ['Learned a few things', 'Learned everything', 'Learned nothing']) # Now ensure the acid_aside is not in the result - self.assertNotRegexpMatches(problem_html, r"data-block-type=[\"\']acid_aside[\"\']") + self.assertNotRegexpMatches(problem_html, r"data-block-type=[\"\']acid_aside[\"\']") # lint-amnesty, pylint: disable=deprecated-method # Ensure about video don't have asides video_html = get_preview_fragment(request, self.video, context).content - self.assertNotRegexpMatches(video_html, " Date: Tue, 2 Feb 2021 15:31:33 +0500 Subject: [PATCH 15/19] pylint amnesty in cms apps --- cms/djangoapps/course_creators/admin.py | 8 ++++---- cms/djangoapps/course_creators/models.py | 4 ++-- cms/djangoapps/course_creators/tests/test_admin.py | 4 ++-- cms/djangoapps/course_creators/tests/test_views.py | 4 ++-- cms/djangoapps/maintenance/tests.py | 10 +++++----- cms/djangoapps/maintenance/views.py | 14 +++++++------- cms/djangoapps/models/settings/course_grading.py | 14 +++++++------- cms/djangoapps/models/settings/course_metadata.py | 6 +++--- cms/djangoapps/models/settings/encoder.py | 2 +- cms/djangoapps/xblock_config/tests/test_models.py | 2 +- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/cms/djangoapps/course_creators/admin.py b/cms/djangoapps/course_creators/admin.py index 5b607eb603..3c41cd5370 100644 --- a/cms/djangoapps/course_creators/admin.py +++ b/cms/djangoapps/course_creators/admin.py @@ -80,7 +80,7 @@ admin.site.register(CourseCreator, CourseCreatorAdmin) @receiver(update_creator_state, sender=CourseCreator) -def update_creator_group_callback(sender, **kwargs): +def update_creator_group_callback(sender, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Callback for when the model's creator status has changed. """ @@ -90,7 +90,7 @@ def update_creator_group_callback(sender, **kwargs): @receiver(send_user_notification, sender=CourseCreator) -def send_user_notification_callback(sender, **kwargs): +def send_user_notification_callback(sender, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Callback for notifying user about course creator status change. """ @@ -113,12 +113,12 @@ def send_user_notification_callback(sender, **kwargs): try: user.email_user(subject, message, studio_request_email) - except: + except: # lint-amnesty, pylint: disable=bare-except log.warning(u"Unable to send course creator status e-mail to %s", user.email) @receiver(send_admin_notification, sender=CourseCreator) -def send_admin_notification_callback(sender, **kwargs): +def send_admin_notification_callback(sender, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Callback for notifying admin of a user in the 'pending' state. """ diff --git a/cms/djangoapps/course_creators/models.py b/cms/djangoapps/course_creators/models.py index bfb09a0c30..2b2c8a0129 100644 --- a/cms/djangoapps/course_creators/models.py +++ b/cms/djangoapps/course_creators/models.py @@ -3,7 +3,7 @@ Table for storing information about whether or not Studio users have course crea """ -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.db import models from django.db.models.signals import post_init, post_save from django.dispatch import Signal, receiver @@ -54,7 +54,7 @@ class CourseCreator(models.Model): @receiver(post_init, sender=CourseCreator) -def post_init_callback(sender, **kwargs): +def post_init_callback(sender, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Extend to store previous state. """ diff --git a/cms/djangoapps/course_creators/tests/test_admin.py b/cms/djangoapps/course_creators/tests/test_admin.py index 4905e90bb8..75c329306b 100644 --- a/cms/djangoapps/course_creators/tests/test_admin.py +++ b/cms/djangoapps/course_creators/tests/test_admin.py @@ -5,7 +5,7 @@ Tests course_creators.admin.py. import mock from django.contrib.admin.sites import AdminSite -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core import mail from django.http import HttpRequest from django.test import TestCase @@ -29,7 +29,7 @@ class CourseCreatorAdminTest(TestCase): def setUp(self): """ Test case setup """ - super(CourseCreatorAdminTest, self).setUp() + super(CourseCreatorAdminTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = User.objects.create_user('test_user', 'test_user+courses@edx.org', 'foo') self.table_entry = CourseCreator(user=self.user) self.table_entry.save() diff --git a/cms/djangoapps/course_creators/tests/test_views.py b/cms/djangoapps/course_creators/tests/test_views.py index 78493ce857..7618c207ee 100644 --- a/cms/djangoapps/course_creators/tests/test_views.py +++ b/cms/djangoapps/course_creators/tests/test_views.py @@ -4,7 +4,7 @@ Tests course_creators.views.py. import mock -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import PermissionDenied from django.test import TestCase from django.urls import reverse @@ -27,7 +27,7 @@ class CourseCreatorView(TestCase): def setUp(self): """ Test case setup """ - super(CourseCreatorView, self).setUp() + super(CourseCreatorView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = User.objects.create_user('test_user', 'test_user+courses@edx.org', 'foo') self.admin = User.objects.create_user('Mark', 'admin+courses@edx.org', 'foo') self.admin.is_staff = True diff --git a/cms/djangoapps/maintenance/tests.py b/cms/djangoapps/maintenance/tests.py index 6200aa8e1e..c324be9b1d 100644 --- a/cms/djangoapps/maintenance/tests.py +++ b/cms/djangoapps/maintenance/tests.py @@ -30,7 +30,7 @@ class TestMaintenanceIndex(ModuleStoreTestCase): """ def setUp(self): - super(TestMaintenanceIndex, self).setUp() + super(TestMaintenanceIndex, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = AdminFactory() login_success = self.client.login(username=self.user.username, password='test') self.assertTrue(login_success) @@ -56,7 +56,7 @@ class MaintenanceViewTestCase(ModuleStoreTestCase): view_url = '' def setUp(self): - super(MaintenanceViewTestCase, self).setUp() + super(MaintenanceViewTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = AdminFactory() login_success = self.client.login(username=self.user.username, password='test') self.assertTrue(login_success) @@ -73,7 +73,7 @@ class MaintenanceViewTestCase(ModuleStoreTestCase): Reverse the setup. """ self.client.logout() - super(MaintenanceViewTestCase, self).tearDown() + super(MaintenanceViewTestCase, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments @ddt.ddt @@ -131,7 +131,7 @@ class TestForcePublish(MaintenanceViewTestCase): """ def setUp(self): - super(TestForcePublish, self).setUp() + super(TestForcePublish, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.view_url = reverse('maintenance:force_publish_course') def setup_test_course(self): @@ -271,7 +271,7 @@ class TestAnnouncementsViews(MaintenanceViewTestCase): """ def setUp(self): - super(TestAnnouncementsViews, self).setUp() + super(TestAnnouncementsViews, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.admin = AdminFactory.create( email='staff@edx.org', username='admin', diff --git a/cms/djangoapps/maintenance/views.py b/cms/djangoapps/maintenance/views.py index 207966960e..ba80d6500c 100644 --- a/cms/djangoapps/maintenance/views.py +++ b/cms/djangoapps/maintenance/views.py @@ -84,7 +84,7 @@ class MaintenanceBaseView(View): template = 'maintenance/container.html' def __init__(self, view=None): - super(MaintenanceBaseView, self).__init__() + super(MaintenanceBaseView, self).__init__() # lint-amnesty, pylint: disable=super-with-arguments self.context = { 'view': view if view else '', 'form_data': {}, @@ -142,7 +142,7 @@ class ForcePublishCourseView(MaintenanceBaseView): """ def __init__(self): - super(ForcePublishCourseView, self).__init__(MAINTENANCE_VIEWS['force_publish_course']) + super(ForcePublishCourseView, self).__init__(MAINTENANCE_VIEWS['force_publish_course']) # lint-amnesty, pylint: disable=super-with-arguments self.context.update({ 'current_versions': [], 'updated_versions': [], @@ -238,7 +238,7 @@ class AnnouncementBaseView(View): @method_decorator(require_global_staff) def dispatch(self, request, *args, **kwargs): - return super(AnnouncementBaseView, self).dispatch(request, *args, **kwargs) + return super(AnnouncementBaseView, self).dispatch(request, *args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments class AnnouncementIndexView(ListView, MaintenanceBaseView): @@ -251,10 +251,10 @@ class AnnouncementIndexView(ListView, MaintenanceBaseView): paginate_by = 8 def __init__(self): - super(AnnouncementIndexView, self).__init__(MAINTENANCE_VIEWS['announcement_index']) + super(AnnouncementIndexView, self).__init__(MAINTENANCE_VIEWS['announcement_index']) # lint-amnesty, pylint: disable=super-with-arguments def get_context_data(self, **kwargs): - context = super(AnnouncementIndexView, self).get_context_data(**kwargs) + context = super(AnnouncementIndexView, self).get_context_data(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments context['view'] = MAINTENANCE_VIEWS['announcement_index'] return context @@ -274,7 +274,7 @@ class AnnouncementEditView(UpdateView, AnnouncementBaseView): template_name = '/maintenance/_announcement_edit.html' def get_context_data(self, **kwargs): - context = super(AnnouncementEditView, self).get_context_data(**kwargs) + context = super(AnnouncementEditView, self).get_context_data(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments context['action_url'] = reverse('maintenance:announcement_edit', kwargs={'pk': context['announcement'].pk}) return context @@ -289,7 +289,7 @@ class AnnouncementCreateView(CreateView, AnnouncementBaseView): template_name = '/maintenance/_announcement_edit.html' def get_context_data(self, **kwargs): - context = super(AnnouncementCreateView, self).get_context_data(**kwargs) + context = super(AnnouncementCreateView, self).get_context_data(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments context['action_url'] = reverse('maintenance:announcement_create') return context diff --git a/cms/djangoapps/models/settings/course_grading.py b/cms/djangoapps/models/settings/course_grading.py index 3cc7ff00df..738b31f2fe 100644 --- a/cms/djangoapps/models/settings/course_grading.py +++ b/cms/djangoapps/models/settings/course_grading.py @@ -235,7 +235,7 @@ class CourseGradingModel(object): # 'minimum_grade_credit' cannot be set to None if minimum_grade_credit is not None: - minimum_grade_credit = minimum_grade_credit + minimum_grade_credit = minimum_grade_credit # lint-amnesty, pylint: disable=self-assigning-variable descriptor.minimum_grade_credit = minimum_grade_credit modulestore().update_item(descriptor, user.id) @@ -276,7 +276,7 @@ class CourseGradingModel(object): } @staticmethod - def update_section_grader_type(descriptor, grader_type, user): + def update_section_grader_type(descriptor, grader_type, user): # lint-amnesty, pylint: disable=missing-function-docstring if grader_type is not None and grader_type != u'notgraded': descriptor.format = grader_type descriptor.graded = True @@ -289,7 +289,7 @@ class CourseGradingModel(object): return {'graderType': grader_type} @staticmethod - def convert_set_grace_period(descriptor): + def convert_set_grace_period(descriptor): # lint-amnesty, pylint: disable=missing-function-docstring # 5 hours 59 minutes 59 seconds => converted to iso format rawgrace = descriptor.graceperiod if rawgrace: @@ -316,7 +316,7 @@ class CourseGradingModel(object): return None @staticmethod - def parse_grader(json_grader): + def parse_grader(json_grader): # lint-amnesty, pylint: disable=missing-function-docstring # manual to clear out kruft result = {"type": json_grader["type"], "min_count": int(json_grader.get('min_count', 0)), @@ -328,7 +328,7 @@ class CourseGradingModel(object): return result @staticmethod - def jsonize_grader(i, grader): + def jsonize_grader(i, grader): # lint-amnesty, pylint: disable=missing-function-docstring # Warning: converting weight to integer might give unwanted results due # to the reason how floating point arithmetic works # e.g, "0.29 * 100 = 28.999999999999996" @@ -342,7 +342,7 @@ class CourseGradingModel(object): } -def _grading_event_and_signal(course_key, user_id): +def _grading_event_and_signal(course_key, user_id): # lint-amnesty, pylint: disable=missing-function-docstring name = GRADING_POLICY_CHANGED_EVENT_TYPE course = modulestore().get_course(course_key) grading_policy_hash = six.text_type(hash_grading_policy(course.grading_policy)) @@ -362,7 +362,7 @@ def _grading_event_and_signal(course_key, user_id): ) -def hash_grading_policy(grading_policy): +def hash_grading_policy(grading_policy): # lint-amnesty, pylint: disable=missing-function-docstring ordered_policy = json.dumps( grading_policy, separators=(',', ':'), # Remove spaces from separators for more compact representation diff --git a/cms/djangoapps/models/settings/course_metadata.py b/cms/djangoapps/models/settings/course_metadata.py index cd3e5d5884..534f182799 100644 --- a/cms/djangoapps/models/settings/course_metadata.py +++ b/cms/djangoapps/models/settings/course_metadata.py @@ -173,14 +173,14 @@ class CourseMetadata(object): if field.scope != Scope.settings: continue - field_help = _(field.help) + field_help = _(field.help) # lint-amnesty, pylint: disable=translation-of-non-string help_args = field.runtime_options.get('help_format_args') if help_args is not None: field_help = field_help.format(**help_args) result[field.name] = { 'value': field.read_json(descriptor), - 'display_name': _(field.display_name), + 'display_name': _(field.display_name), # lint-amnesty, pylint: disable=translation-of-non-string 'help': field_help, 'deprecated': field.runtime_options.get('deprecated', False), 'hide_on_enabled_publisher': field.runtime_options.get('hide_on_enabled_publisher', False) @@ -211,7 +211,7 @@ class CourseMetadata(object): if hasattr(descriptor, key) and getattr(descriptor, key) != val: key_values[key] = descriptor.fields[key].from_json(val) except (TypeError, ValueError) as err: - raise ValueError(_(u"Incorrect format for field '{name}'. {detailed_message}").format( + raise ValueError(_(u"Incorrect format for field '{name}'. {detailed_message}").format( # lint-amnesty, pylint: disable=raise-missing-from name=model['display_name'], detailed_message=text_type(err))) return cls.update_from_dict(key_values, descriptor, user) diff --git a/cms/djangoapps/models/settings/encoder.py b/cms/djangoapps/models/settings/encoder.py index 8451207a35..133ae1fda0 100644 --- a/cms/djangoapps/models/settings/encoder.py +++ b/cms/djangoapps/models/settings/encoder.py @@ -20,7 +20,7 @@ class CourseSettingsEncoder(json.JSONEncoder): Serialize CourseDetails, CourseGradingModel, datetime, and old Locations """ - def default(self, obj): # pylint: disable=method-hidden + def default(self, obj): # lint-amnesty, pylint: disable=arguments-differ, method-hidden if isinstance(obj, (CourseDetails, CourseGradingModel)): return obj.__dict__ elif isinstance(obj, Location): diff --git a/cms/djangoapps/xblock_config/tests/test_models.py b/cms/djangoapps/xblock_config/tests/test_models.py index 4fe2c88f1e..7b6c4db288 100644 --- a/cms/djangoapps/xblock_config/tests/test_models.py +++ b/cms/djangoapps/xblock_config/tests/test_models.py @@ -34,7 +34,7 @@ class TestLTIConsumerHideFieldsFlag(TestCase): These are set via Django admin settings. """ def setUp(self): - super(TestLTIConsumerHideFieldsFlag, self).setUp() + super(TestLTIConsumerHideFieldsFlag, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_id = CourseLocator(org="edx", course="course", run="run") @ddt.data( From 9e677960bf1ac46b5a205ec932c4157833d88629 Mon Sep 17 00:00:00 2001 From: Jawayria Date: Tue, 2 Feb 2021 15:42:02 +0500 Subject: [PATCH 16/19] Applied pylint-amnesty to common/{lib, test, __init__.py} --- common/test/acceptance/fixtures/base.py | 12 +++--- .../test/acceptance/fixtures/certificates.py | 6 +-- common/test/acceptance/fixtures/config.py | 4 +- common/test/acceptance/fixtures/course.py | 12 +++--- common/test/acceptance/fixtures/discussion.py | 18 ++++---- common/test/acceptance/fixtures/library.py | 6 +-- .../test/acceptance/pages/common/auto_auth.py | 2 +- common/test/acceptance/pages/common/utils.py | 2 +- common/test/acceptance/pages/lms/catalog.py | 2 +- .../test/acceptance/pages/lms/course_home.py | 2 +- .../test/acceptance/pages/lms/course_page.py | 4 +- .../test/acceptance/pages/lms/course_wiki.py | 2 +- .../test/acceptance/pages/lms/courseware.py | 4 +- .../test/acceptance/pages/lms/discussion.py | 8 ++-- common/test/acceptance/pages/lms/fields.py | 2 +- .../acceptance/pages/lms/learner_profile.py | 4 +- .../test/acceptance/pages/lms/staff_view.py | 2 +- .../test/acceptance/pages/lms/video/video.py | 4 +- .../test/acceptance/pages/studio/container.py | 26 ++++++------ .../acceptance/pages/studio/course_page.py | 4 +- .../test/acceptance/pages/studio/library.py | 4 +- .../test/acceptance/pages/studio/overview.py | 18 ++++---- common/test/acceptance/pages/studio/users.py | 2 +- common/test/acceptance/pages/studio/utils.py | 4 +- .../acceptance/pages/studio/video/video.py | 8 ++-- .../acceptance/tests/discussion/helpers.py | 8 ++-- .../discussion/test_cohort_management.py | 2 +- .../tests/discussion/test_discussion.py | 34 +++++++-------- common/test/acceptance/tests/helpers.py | 14 +++---- common/test/acceptance/tests/lms/test_lms.py | 2 +- .../tests/lms/test_lms_course_home.py | 2 +- .../tests/lms/test_lms_dashboard.py | 2 +- .../lms/test_lms_instructor_dashboard.py | 10 ++--- .../acceptance/tests/lms/test_lms_problems.py | 2 +- .../tests/lms/test_lms_user_preview.py | 12 +++--- .../tests/lms/test_problem_types.py | 42 +++++++++---------- .../acceptance/tests/lms/test_programs.py | 6 +-- .../tests/lms/test_progress_page.py | 10 ++--- .../tests/studio/base_studio_test.py | 16 +++---- .../tests/studio/test_studio_settings.py | 4 +- .../tests/video/test_video_module.py | 4 +- common/test/utils.py | 10 ++--- 42 files changed, 171 insertions(+), 171 deletions(-) diff --git a/common/test/acceptance/fixtures/base.py b/common/test/acceptance/fixtures/base.py index 6979a6440b..f415e11f48 100644 --- a/common/test/acceptance/fixtures/base.py +++ b/common/test/acceptance/fixtures/base.py @@ -6,7 +6,7 @@ Common code shared by course and library fixtures. import json import requests -import six +import six # lint-amnesty, pylint: disable=unused-import from lazy import lazy from common.test.acceptance.fixtures import STUDIO_BASE_URL @@ -16,7 +16,7 @@ class StudioApiLoginError(Exception): """ Error occurred while logging in to the Studio API. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class StudioApiFixture(object): @@ -57,7 +57,7 @@ class StudioApiFixture(object): Log in as a staff user, then return the cookies for the session (as a dict) Raises a `StudioApiLoginError` if the login fails. """ - return {key: val for key, val in self.session.cookies.items()} + return {key: val for key, val in self.session.cookies.items()} # lint-amnesty, pylint: disable=unnecessary-comprehension @lazy def headers(self): @@ -75,7 +75,7 @@ class FixtureError(Exception): """ Error occurred while installing a course or library fixture. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class XBlockContainerFixture(StudioApiFixture): @@ -85,7 +85,7 @@ class XBlockContainerFixture(StudioApiFixture): def __init__(self): self.children = [] - super(XBlockContainerFixture, self).__init__() + super(XBlockContainerFixture, self).__init__() # lint-amnesty, pylint: disable=super-with-arguments def add_children(self, *args): """ @@ -133,7 +133,7 @@ class XBlockContainerFixture(StudioApiFixture): loc = response.json().get('locator') xblock_desc.locator = loc except ValueError: - raise FixtureError(u"Could not decode JSON from '{0}'".format(response.content)) + raise FixtureError(u"Could not decode JSON from '{0}'".format(response.content)) # lint-amnesty, pylint: disable=raise-missing-from # Configure the XBlock response = self.session.post( diff --git a/common/test/acceptance/fixtures/certificates.py b/common/test/acceptance/fixtures/certificates.py index b8e613a766..ff4ed291e5 100644 --- a/common/test/acceptance/fixtures/certificates.py +++ b/common/test/acceptance/fixtures/certificates.py @@ -13,14 +13,14 @@ class CertificateConfigFixtureError(Exception): """ Error occurred while installing certificate config fixture. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class CertificateConfigUpdateFixtureError(Exception): """ Error occurred while updating certificate config fixture. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class CertificateConfigFixture(StudioApiFixture): @@ -32,7 +32,7 @@ class CertificateConfigFixture(StudioApiFixture): def __init__(self, course_id, certificates_data): self.course_id = course_id self.certificates = certificates_data - super(CertificateConfigFixture, self).__init__() + super(CertificateConfigFixture, self).__init__() # lint-amnesty, pylint: disable=super-with-arguments def install(self): """ diff --git a/common/test/acceptance/fixtures/config.py b/common/test/acceptance/fixtures/config.py index ad6152be12..9ee545a98f 100644 --- a/common/test/acceptance/fixtures/config.py +++ b/common/test/acceptance/fixtures/config.py @@ -17,7 +17,7 @@ class ConfigModelFixtureError(Exception): """ Error occurred while configuring the stub XQueue. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class ConfigModelFixture(object): @@ -62,7 +62,7 @@ class ConfigModelFixture(object): Log in as a staff user, then return the cookies for the session (as a dict) Raises a `ConfigModelFixtureError` if the login fails. """ - return {key: val for key, val in self.session.cookies.items()} + return {key: val for key, val in self.session.cookies.items()} # lint-amnesty, pylint: disable=unnecessary-comprehension @lazy def headers(self): diff --git a/common/test/acceptance/fixtures/course.py b/common/test/acceptance/fixtures/course.py index 5bc2ef728d..edc44e4e45 100644 --- a/common/test/acceptance/fixtures/course.py +++ b/common/test/acceptance/fixtures/course.py @@ -120,7 +120,7 @@ class CourseFixture(XBlockContainerFixture): to enable entrance exam settings would be a dict like this {"entrance_exam_enabled": "true"} These have the same meaning as in the Studio restful API /course end-point. """ - super(CourseFixture, self).__init__() + super(CourseFixture, self).__init__() # lint-amnesty, pylint: disable=super-with-arguments self._course_dict = { 'org': org, 'number': number, @@ -242,7 +242,7 @@ class CourseFixture(XBlockContainerFixture): try: course_outline_json = response.json() except ValueError: - raise FixtureError( + raise FixtureError( # lint-amnesty, pylint: disable=raise-missing-from u"Could not decode course outline as JSON: '{0}'".format(response) ) return course_outline_json @@ -290,7 +290,7 @@ class CourseFixture(XBlockContainerFixture): err = response.json().get('ErrMsg') except ValueError: - raise FixtureError( + raise FixtureError( # lint-amnesty, pylint: disable=raise-missing-from u"Could not parse response from course request as JSON: '{0}'".format( response.content)) @@ -322,7 +322,7 @@ class CourseFixture(XBlockContainerFixture): try: details = response.json() except ValueError: - raise FixtureError( + raise FixtureError( # lint-amnesty, pylint: disable=raise-missing-from u"Could not decode course details as JSON: '{0}'".format(details) ) @@ -397,7 +397,7 @@ class CourseFixture(XBlockContainerFixture): for asset_name in self._assets: asset_file_path = test_dir + '/data/uploads/' + asset_name - asset_file = open(asset_file_path, mode='rb') # pylint: disable=open-builtin + asset_file = open(asset_file_path, mode='rb') # lint-amnesty, pylint: disable=bad-option-value, open-builtin files = {'file': (asset_name, asset_file, mimetypes.guess_type(asset_file_path)[0])} headers = { @@ -447,5 +447,5 @@ class CourseFixture(XBlockContainerFixture): """ Recursively create XBlock children. """ - super(CourseFixture, self)._create_xblock_children(parent_loc, xblock_descriptions) + super(CourseFixture, self)._create_xblock_children(parent_loc, xblock_descriptions) # lint-amnesty, pylint: disable=super-with-arguments self._publish_xblock(parent_loc) diff --git a/common/test/acceptance/fixtures/discussion.py b/common/test/acceptance/fixtures/discussion.py index 3e507c0bec..1e1bf99ce8 100644 --- a/common/test/acceptance/fixtures/discussion.py +++ b/common/test/acceptance/fixtures/discussion.py @@ -13,7 +13,7 @@ from common.test.acceptance.fixtures import COMMENTS_STUB_URL from common.test.acceptance.fixtures.config import ConfigModelFixture -class ContentFactory(factory.Factory): +class ContentFactory(factory.Factory): # lint-amnesty, pylint: disable=missing-class-docstring class Meta(object): model = dict @@ -40,7 +40,7 @@ class ContentFactory(factory.Factory): return kwargs -class Thread(ContentFactory): +class Thread(ContentFactory): # lint-amnesty, pylint: disable=missing-class-docstring thread_type = "discussion" anonymous = False anonymous_to_peers = False @@ -67,7 +67,7 @@ class Response(Comment): body = "dummy response body" -class SearchResult(factory.Factory): +class SearchResult(factory.Factory): # lint-amnesty, pylint: disable=missing-class-docstring class Meta(object): model = dict @@ -78,7 +78,7 @@ class SearchResult(factory.Factory): corrected_text = None -class DiscussionContentFixture(object): +class DiscussionContentFixture(object): # lint-amnesty, pylint: disable=missing-class-docstring def push(self): """ @@ -96,12 +96,12 @@ class DiscussionContentFixture(object): raise NotImplementedError() -class SingleThreadViewFixture(DiscussionContentFixture): +class SingleThreadViewFixture(DiscussionContentFixture): # lint-amnesty, pylint: disable=missing-class-docstring def __init__(self, thread): self.thread = thread - def addResponse(self, response, comments=[]): + def addResponse(self, response, comments=[]): # lint-amnesty, pylint: disable=dangerous-default-value, missing-function-docstring response['children'] = comments if self.thread["thread_type"] == "discussion": responseListAttr = "children" @@ -133,7 +133,7 @@ class SingleThreadViewFixture(DiscussionContentFixture): } -class MultipleThreadFixture(DiscussionContentFixture): +class MultipleThreadFixture(DiscussionContentFixture): # lint-amnesty, pylint: disable=missing-class-docstring def __init__(self, threads): self.threads = threads @@ -157,7 +157,7 @@ class MultipleThreadFixture(DiscussionContentFixture): thread['comments_count'] += len(comments) + 1 -class UserProfileViewFixture(DiscussionContentFixture): +class UserProfileViewFixture(DiscussionContentFixture): # lint-amnesty, pylint: disable=missing-class-docstring def __init__(self, threads): self.threads = threads @@ -166,7 +166,7 @@ class UserProfileViewFixture(DiscussionContentFixture): return {"active_threads": json.dumps(self.threads)} -class SearchResultFixture(DiscussionContentFixture): +class SearchResultFixture(DiscussionContentFixture): # lint-amnesty, pylint: disable=missing-class-docstring def __init__(self, result): self.result = result diff --git a/common/test/acceptance/fixtures/library.py b/common/test/acceptance/fixtures/library.py index a00f972ef5..0fd4a4ea64 100644 --- a/common/test/acceptance/fixtures/library.py +++ b/common/test/acceptance/fixtures/library.py @@ -22,7 +22,7 @@ class LibraryFixture(XBlockContainerFixture): """ Configure the library fixture to create a library with """ - super(LibraryFixture, self).__init__() + super(LibraryFixture, self).__init__() # lint-amnesty, pylint: disable=super-with-arguments self.library_info = { 'org': org, 'number': number, @@ -31,7 +31,7 @@ class LibraryFixture(XBlockContainerFixture): self.display_name = display_name self._library_key = None - super(LibraryFixture, self).__init__() + super(LibraryFixture, self).__init__() # lint-amnesty, pylint: disable=super-with-arguments def __str__(self): """ @@ -92,4 +92,4 @@ class LibraryFixture(XBlockContainerFixture): # Disable publishing for library XBlocks: xblock_desc.publish = "not-applicable" - return super(LibraryFixture, self).create_xblock(parent_loc, xblock_desc) + return super(LibraryFixture, self).create_xblock(parent_loc, xblock_desc) # lint-amnesty, pylint: disable=super-with-arguments diff --git a/common/test/acceptance/pages/common/auto_auth.py b/common/test/acceptance/pages/common/auto_auth.py index 0e11d7d039..8a7b11d9e8 100644 --- a/common/test/acceptance/pages/common/auto_auth.py +++ b/common/test/acceptance/pages/common/auto_auth.py @@ -45,7 +45,7 @@ class AutoAuthPage(PageObject): Note that "global staff" is NOT the same as course staff. """ - super(AutoAuthPage, self).__init__(browser) + super(AutoAuthPage, self).__init__(browser) # lint-amnesty, pylint: disable=super-with-arguments # This will eventually hold the details about the user account self._user_info = None diff --git a/common/test/acceptance/pages/common/utils.py b/common/test/acceptance/pages/common/utils.py index beff6a78a1..4bdea6fb98 100644 --- a/common/test/acceptance/pages/common/utils.py +++ b/common/test/acceptance/pages/common/utils.py @@ -43,4 +43,4 @@ def confirm_prompt(page, cancel=False, require_notification=None): confirmation_button_css = '.prompt .action-' + ('secondary' if cancel else 'primary') page.wait_for_element_visibility(confirmation_button_css, 'Confirmation button is visible') require_notification = (not cancel) if require_notification is None else require_notification - click_css(page, confirmation_button_css, require_notification=require_notification) + click_css(page, confirmation_button_css, require_notification=require_notification) # lint-amnesty, pylint: disable=unexpected-keyword-arg diff --git a/common/test/acceptance/pages/lms/catalog.py b/common/test/acceptance/pages/lms/catalog.py index ad077f416b..1930b11261 100644 --- a/common/test/acceptance/pages/lms/catalog.py +++ b/common/test/acceptance/pages/lms/catalog.py @@ -24,4 +24,4 @@ class CacheProgramsPage(PageObject): body = self.q(css='body').text[0] match = re.search(r'programs cached', body, flags=re.IGNORECASE) - return True if match else False + return True if match else False # lint-amnesty, pylint: disable=simplifiable-if-expression diff --git a/common/test/acceptance/pages/lms/course_home.py b/common/test/acceptance/pages/lms/course_home.py index 08121cd057..20e024a877 100644 --- a/common/test/acceptance/pages/lms/course_home.py +++ b/common/test/acceptance/pages/lms/course_home.py @@ -20,7 +20,7 @@ class CourseHomePage(CoursePage): return self.q(css='.course-outline').present def __init__(self, browser, course_id): - super(CourseHomePage, self).__init__(browser, course_id) + super(CourseHomePage, self).__init__(browser, course_id) # lint-amnesty, pylint: disable=super-with-arguments self.course_id = course_id self.preview = StaffPreviewPage(browser, self) # TODO: TNL-6546: Remove the following diff --git a/common/test/acceptance/pages/lms/course_page.py b/common/test/acceptance/pages/lms/course_page.py index 737ed78b16..1b0b9a8b0e 100644 --- a/common/test/acceptance/pages/lms/course_page.py +++ b/common/test/acceptance/pages/lms/course_page.py @@ -9,7 +9,7 @@ from common.test.acceptance.pages.lms import BASE_URL from common.test.acceptance.pages.lms.tab_nav import TabNavPage -class CoursePage(PageObject): +class CoursePage(PageObject): # lint-amnesty, pylint: disable=abstract-method """ Abstract base class for page objects within a course. """ @@ -23,7 +23,7 @@ class CoursePage(PageObject): Course ID is currently of the form "edx/999/2013_Spring" but this format could change. """ - super(CoursePage, self).__init__(browser) + super(CoursePage, self).__init__(browser) # lint-amnesty, pylint: disable=super-with-arguments self.course_id = course_id @property diff --git a/common/test/acceptance/pages/lms/course_wiki.py b/common/test/acceptance/pages/lms/course_wiki.py index f15a67bc85..af675ba224 100644 --- a/common/test/acceptance/pages/lms/course_wiki.py +++ b/common/test/acceptance/pages/lms/course_wiki.py @@ -57,7 +57,7 @@ class CourseWikiSubviewPage(CoursePage): # pylint: disable=abstract-method Course ID is currently of the form "edx/999/2013_Spring" but this format could change. """ - super(CourseWikiSubviewPage, self).__init__(browser, course_id) + super(CourseWikiSubviewPage, self).__init__(browser, course_id) # lint-amnesty, pylint: disable=super-with-arguments self.course_id = course_id self.course_info = course_info self.article_name = "{org}.{course_number}.{course_run}".format( diff --git a/common/test/acceptance/pages/lms/courseware.py b/common/test/acceptance/pages/lms/courseware.py index 2b06f499d0..222d946b53 100644 --- a/common/test/acceptance/pages/lms/courseware.py +++ b/common/test/acceptance/pages/lms/courseware.py @@ -20,8 +20,8 @@ class CoursewarePage(CoursePage): section_selector = '.chapter' subsection_selector = '.chapter-content-container a' - def __init__(self, browser, course_id): - super(CoursewarePage, self).__init__(browser, course_id) + def __init__(self, browser, course_id): # lint-amnesty, pylint: disable=useless-super-delegation + super(CoursewarePage, self).__init__(browser, course_id) # lint-amnesty, pylint: disable=super-with-arguments # self.nav = CourseNavPage(browser, self) def is_browser_on_page(self): diff --git a/common/test/acceptance/pages/lms/discussion.py b/common/test/acceptance/pages/lms/discussion.py index 711b8eec5f..9ba7b6a12b 100644 --- a/common/test/acceptance/pages/lms/discussion.py +++ b/common/test/acceptance/pages/lms/discussion.py @@ -18,7 +18,7 @@ class DiscussionThreadPage(PageObject): url = None def __init__(self, browser, thread_selector): - super(DiscussionThreadPage, self).__init__(browser) + super(DiscussionThreadPage, self).__init__(browser) # lint-amnesty, pylint: disable=super-with-arguments self.thread_selector = thread_selector def _find_within(self, selector): @@ -74,9 +74,9 @@ class DiscussionThreadPage(PageObject): ).fulfill() -class DiscussionTabSingleThreadPage(CoursePage): +class DiscussionTabSingleThreadPage(CoursePage): # lint-amnesty, pylint: disable=missing-class-docstring def __init__(self, browser, course_id, discussion_id, thread_id): - super(DiscussionTabSingleThreadPage, self).__init__(browser, course_id) + super(DiscussionTabSingleThreadPage, self).__init__(browser, course_id) # lint-amnesty, pylint: disable=super-with-arguments self.thread_page = DiscussionThreadPage( browser, u"body.discussion .discussion-article[data-id='{thread_id}']".format(thread_id=thread_id) @@ -103,7 +103,7 @@ class DiscussionTabHomePage(CoursePage): ALERT_SELECTOR = ".discussion-body .forum-nav .search-alert" def __init__(self, browser, course_id): - super(DiscussionTabHomePage, self).__init__(browser, course_id) + super(DiscussionTabHomePage, self).__init__(browser, course_id) # lint-amnesty, pylint: disable=super-with-arguments self.url_path = "discussion/forum/" self.root_selector = None diff --git a/common/test/acceptance/pages/lms/fields.py b/common/test/acceptance/pages/lms/fields.py index 28dc541467..9369f4b375 100644 --- a/common/test/acceptance/pages/lms/fields.py +++ b/common/test/acceptance/pages/lms/fields.py @@ -245,7 +245,7 @@ class FieldsMixin(object): Returns bool based on the highlighted border for field. """ query = self.q(css=u'.u-field-{}.error'.format(field_id)) - return True if query.present else False + return True if query.present else False # lint-amnesty, pylint: disable=simplifiable-if-expression def get_social_first_element(self): """ diff --git a/common/test/acceptance/pages/lms/learner_profile.py b/common/test/acceptance/pages/lms/learner_profile.py index 1de4b84ca6..cc0de5759f 100644 --- a/common/test/acceptance/pages/lms/learner_profile.py +++ b/common/test/acceptance/pages/lms/learner_profile.py @@ -25,7 +25,7 @@ class Badge(PageObject): def __init__(self, element, browser): self.element = element - super(Badge, self).__init__(browser) + super(Badge, self).__init__(browser) # lint-amnesty, pylint: disable=super-with-arguments def is_browser_on_page(self): return BrowserQuery(self.element, css=".badge-details").visible @@ -84,7 +84,7 @@ class LearnerProfilePage(FieldsMixin, PageObject): browser (Browser): The browser instance. username (str): Profile username. """ - super(LearnerProfilePage, self).__init__(browser) + super(LearnerProfilePage, self).__init__(browser) # lint-amnesty, pylint: disable=super-with-arguments self.username = username @property diff --git a/common/test/acceptance/pages/lms/staff_view.py b/common/test/acceptance/pages/lms/staff_view.py index 630e00af93..c9b89b3a54 100644 --- a/common/test/acceptance/pages/lms/staff_view.py +++ b/common/test/acceptance/pages/lms/staff_view.py @@ -28,7 +28,7 @@ class StaffPreviewPage(PageObject): parent_page: None if this is being used as a subclass. Otherwise, the parent_page the contains this staff preview page fragment. """ - super(StaffPreviewPage, self).__init__(browser) + super(StaffPreviewPage, self).__init__(browser) # lint-amnesty, pylint: disable=super-with-arguments self.parent_page = parent_page def is_browser_on_page(self): diff --git a/common/test/acceptance/pages/lms/video/video.py b/common/test/acceptance/pages/lms/video/video.py index 34c7d04e06..55ce59e76f 100644 --- a/common/test/acceptance/pages/lms/video/video.py +++ b/common/test/acceptance/pages/lms/video/video.py @@ -7,7 +7,7 @@ import logging from bok_choy.javascript import js_defined, wait_for_js from bok_choy.page_object import PageObject -from bok_choy.promise import EmptyPromise, Promise +from bok_choy.promise import EmptyPromise, Promise # lint-amnesty, pylint: disable=unused-import log = logging.getLogger('VideoPage') @@ -220,7 +220,7 @@ class VideoPage(PageObject): # toggle captions visibility state if needed if self.is_captions_visible() != captions_new_state: - self.click_player_button('transcript_button') + self.click_player_button('transcript_button') # lint-amnesty, pylint: disable=no-member # Verify that captions state is toggled/changed EmptyPromise(lambda: self.is_captions_visible() == captions_new_state, diff --git a/common/test/acceptance/pages/studio/container.py b/common/test/acceptance/pages/studio/container.py index a0822788bd..82c3510da3 100644 --- a/common/test/acceptance/pages/studio/container.py +++ b/common/test/acceptance/pages/studio/container.py @@ -22,7 +22,7 @@ class ContainerPage(PageObject, HelpMixin): ADD_MISSING_GROUPS_SELECTOR = '.notification-action-button[data-notification-action="add-missing-groups"]' def __init__(self, browser, locator): - super(ContainerPage, self).__init__(browser) + super(ContainerPage, self).__init__(browser) # lint-amnesty, pylint: disable=super-with-arguments self.locator = locator @property @@ -31,7 +31,7 @@ class ContainerPage(PageObject, HelpMixin): return u"{}/container/{}".format(BASE_URL, self.locator) @property - def name(self): + def name(self): # lint-amnesty, pylint: disable=missing-function-docstring titles = self.q(css=self.NAME_SELECTOR).text if titles: return titles[0] @@ -51,7 +51,7 @@ class ContainerPage(PageObject, HelpMixin): if len(data_request_elements) > 0: request_token = data_request_elements.first.attrs('data-request-token')[0] # Then find the number of Studio xblock wrappers on the page with that request token. - num_wrappers = len(self.q(css=u'{} [data-request-token="{}"]'.format(XBlockWrapper.BODY_SELECTOR, request_token)).results) + num_wrappers = len(self.q(css=u'{} [data-request-token="{}"]'.format(XBlockWrapper.BODY_SELECTOR, request_token)).results) # lint-amnesty, pylint: disable=line-too-long # Wait until all components have been loaded and marked as either initialized or failed. # See: # - common/static/js/xblock/core.js which adds the class "xblock-initialized" @@ -159,9 +159,9 @@ class ContainerPage(PageObject, HelpMixin): if not warnings.is_present(): return False warning_text = warnings.first.text[0] - return warning_text == "Caution: The last published version of this unit is live. By publishing changes you will change the student experience." + return warning_text == "Caution: The last published version of this unit is live. By publishing changes you will change the student experience." # lint-amnesty, pylint: disable=line-too-long - def shows_inherited_staff_lock(self, parent_type=None, parent_name=None): + def shows_inherited_staff_lock(self, parent_type=None, parent_name=None): # lint-amnesty, pylint: disable=unused-argument """ Returns True if the unit inherits staff lock from a section or subsection. """ @@ -187,14 +187,14 @@ class ContainerPage(PageObject, HelpMixin): Publishes the container. """ self.scroll_to_element('.action-publish') - click_css(self, '.action-publish', 0, require_notification=False) + click_css(self, '.action-publish', 0, require_notification=False) # lint-amnesty, pylint: disable=unexpected-keyword-arg def discard_changes(self): """ Discards draft changes (which will then re-render the page). """ self.scroll_to_element('a.action-discard') - click_css(self, 'a.action-discard', 0, require_notification=False) + click_css(self, 'a.action-discard', 0, require_notification=False) # lint-amnesty, pylint: disable=unexpected-keyword-arg confirm_prompt(self) self.wait_for_ajax() @@ -237,7 +237,7 @@ class ContainerPage(PageObject, HelpMixin): if not was_locked_initially: self.q(css='a.action-staff-lock').first.click() else: - click_css(self, 'a.action-staff-lock', 0, require_notification=False) + click_css(self, 'a.action-staff-lock', 0, require_notification=False) # lint-amnesty, pylint: disable=unexpected-keyword-arg if not inherits_staff_lock: confirm_prompt(self) self.wait_for_ajax() @@ -299,7 +299,7 @@ class ContainerPage(PageObject, HelpMixin): The index of the first item is 0. """ # Click the delete button - click_css(self, '.delete-button', source_index, require_notification=False) + click_css(self, '.delete-button', source_index, require_notification=False) # lint-amnesty, pylint: disable=unexpected-keyword-arg # Click the confirmation dialog button confirm_prompt(self) @@ -338,7 +338,7 @@ class ContainerPage(PageObject, HelpMixin): """ Click take me there link. """ - click_css(self, '#page-alert .alert.confirmation .nav-actions .action-secondary', require_notification=False) + click_css(self, '#page-alert .alert.confirmation .nav-actions .action-secondary', require_notification=False) # lint-amnesty, pylint: disable=unexpected-keyword-arg def add_missing_groups(self): """ @@ -433,7 +433,7 @@ class XBlockWrapper(PageObject): } def __init__(self, browser, locator): - super(XBlockWrapper, self).__init__(browser) + super(XBlockWrapper, self).__init__(browser) # lint-amnesty, pylint: disable=super-with-arguments self.locator = locator def is_browser_on_page(self): @@ -465,7 +465,7 @@ class XBlockWrapper(PageObject): return self.q(css=self._bounded_selector('.xblock-author_view'))[0].text @property - def name(self): + def name(self): # lint-amnesty, pylint: disable=missing-function-docstring titles = self.q(css=self._bounded_selector(self.NAME_SELECTOR)).text if titles: return titles[0] @@ -618,7 +618,7 @@ class XBlockWrapper(PageObject): """ Opens the move modal. """ - click_css(self, '.move-button', require_notification=False) + click_css(self, '.move-button', require_notification=False) # lint-amnesty, pylint: disable=unexpected-keyword-arg self.wait_for( lambda: self.q(css='.modal-window.move-modal').visible, description='move modal is visible' ) diff --git a/common/test/acceptance/pages/studio/course_page.py b/common/test/acceptance/pages/studio/course_page.py index 370d78eb7b..0a23be3dc0 100644 --- a/common/test/acceptance/pages/studio/course_page.py +++ b/common/test/acceptance/pages/studio/course_page.py @@ -30,7 +30,7 @@ class CoursePage(PageObject, HelpMixin): Should be implemented in child classes. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def __init__(self, browser, course_org, course_num, course_run): """ @@ -39,7 +39,7 @@ class CoursePage(PageObject, HelpMixin): These identifiers will likely change in the future. """ - super(CoursePage, self).__init__(browser) + super(CoursePage, self).__init__(browser) # lint-amnesty, pylint: disable=super-with-arguments self.course_info = { 'course_org': course_org, 'course_num': course_num, diff --git a/common/test/acceptance/pages/studio/library.py b/common/test/acceptance/pages/studio/library.py index 6a931dca22..c78b2da8bf 100644 --- a/common/test/acceptance/pages/studio/library.py +++ b/common/test/acceptance/pages/studio/library.py @@ -18,7 +18,7 @@ class LibraryPage(PageObject, HelpMixin): Base page for Library pages. Defaults URL to the edit page. """ def __init__(self, browser, locator): - super(LibraryPage, self).__init__(browser) + super(LibraryPage, self).__init__(browser) # lint-amnesty, pylint: disable=super-with-arguments self.locator = locator @property @@ -50,4 +50,4 @@ class LibraryEditPage(LibraryPage, PaginatedMixin, UsersPageMixin): for improved test reliability. """ self.wait_for_ajax() - super(LibraryEditPage, self).wait_until_ready() + super(LibraryEditPage, self).wait_until_ready() # lint-amnesty, pylint: disable=super-with-arguments diff --git a/common/test/acceptance/pages/studio/overview.py b/common/test/acceptance/pages/studio/overview.py index f897922700..409e5e12cb 100644 --- a/common/test/acceptance/pages/studio/overview.py +++ b/common/test/acceptance/pages/studio/overview.py @@ -3,7 +3,7 @@ Course Outline page in Studio. """ -from bok_choy.javascript import js_defined, wait_for_js +from bok_choy.javascript import js_defined, wait_for_js # lint-amnesty, pylint: disable=unused-import from bok_choy.page_object import PageObject from bok_choy.promise import EmptyPromise from selenium.webdriver.support.ui import Select @@ -58,7 +58,7 @@ class CourseOutlineItem(object): Puts the item into editable form. """ self.q(css=self._bounded_selector(self.CONFIGURATION_BUTTON_SELECTOR)).first.click() # pylint: disable=no-member - if 'subsection' in self.BODY_SELECTOR: + if 'subsection' in self.BODY_SELECTOR: # lint-amnesty, pylint: disable=unsupported-membership-test modal = SubsectionOutlineModal(self) else: modal = CourseOutlineModal(self) @@ -105,7 +105,7 @@ class CourseOutlineChild(PageObject, CourseOutlineItem): BODY_SELECTOR = '.outline-item' def __init__(self, browser, locator): - super(CourseOutlineChild, self).__init__(browser) + super(CourseOutlineChild, self).__init__(browser) # lint-amnesty, pylint: disable=super-with-arguments self.locator = locator def is_browser_on_page(self): @@ -160,7 +160,7 @@ class CourseOutlineSubsection(CourseOutlineContainer, CourseOutlineChild): """ Return the :class:`.CourseOutlineUnit with the title `title`. """ - return self.child(title) + return self.child(title) # lint-amnesty, pylint: disable=no-member def units(self): """ @@ -195,7 +195,7 @@ class CourseOutlineSection(CourseOutlineContainer, CourseOutlineChild): """ Return the :class:`.CourseOutlineSubsection` with the title `title`. """ - return self.child(title) + return self.child(title) # lint-amnesty, pylint: disable=no-member def subsections(self): """ @@ -213,7 +213,7 @@ class CourseOutlineSection(CourseOutlineContainer, CourseOutlineChild): """ Adds a subsection to this section """ - self.add_child() + self.add_child() # lint-amnesty, pylint: disable=no-member class ExpandCollapseLinkState(object): @@ -251,7 +251,7 @@ class CourseOutlinePage(CoursePage, CourseOutlineContainer): """ Starts course reindex by clicking reindex button """ - self.reindex_button.click() + self.reindex_button.click() # lint-amnesty, pylint: disable=no-member def open_subsection_settings_dialog(self, index=0): """ @@ -363,7 +363,7 @@ class SubsectionOutlineModal(CourseOutlineModal): """ Returns the current visibility setting for a subsection """ - self.ensure_staff_lock_visible() + self.ensure_staff_lock_visible() # lint-amnesty, pylint: disable=no-member return self.find_css('input[name=content-visibility]:checked').first.attrs('value')[0] @is_explicitly_locked.setter @@ -380,7 +380,7 @@ class SubsectionOutlineModal(CourseOutlineModal): """ Sets the subsection visibility to the given value. """ - self.ensure_staff_lock_visible() + self.ensure_staff_lock_visible() # lint-amnesty, pylint: disable=no-member self.find_css('input[name=content-visibility][value=' + value + ']').click() EmptyPromise(lambda: value == self.subsection_visibility, "Subsection visibility is updated").fulfill() diff --git a/common/test/acceptance/pages/studio/users.py b/common/test/acceptance/pages/studio/users.py index cca2cf2329..b81d226a52 100644 --- a/common/test/acceptance/pages/studio/users.py +++ b/common/test/acceptance/pages/studio/users.py @@ -25,7 +25,7 @@ class UsersPageMixin(PageObject): """ Common functionality for course/library team pages """ new_user_form_selector = '.form-create.create-user .user-email-input' - def url(self): + def url(self): # lint-amnesty, pylint: disable=invalid-overridden-method """ URL to this page - override in subclass """ diff --git a/common/test/acceptance/pages/studio/utils.py b/common/test/acceptance/pages/studio/utils.py index 1da7868054..0dfc60fe66 100644 --- a/common/test/acceptance/pages/studio/utils.py +++ b/common/test/acceptance/pages/studio/utils.py @@ -15,7 +15,7 @@ SIDE_BAR_HELP_CSS = '.external-help a, .external-help-button' @js_defined('window.jQuery') -def type_in_codemirror(page, index, text, find_prefix="$"): +def type_in_codemirror(page, index, text, find_prefix="$"): # lint-amnesty, pylint: disable=missing-function-docstring script = u""" var cm = {find_prefix}('div.CodeMirror:eq({index})').get(0).CodeMirror; CodeMirror.signal(cm, "focus", cm); @@ -71,7 +71,7 @@ def verify_ordering(test_class, page, expected_orderings): expected_length = len(expected_ordering.get(parent)) test_class.assertEqual( expected_length, len(children), - u"Number of children incorrect for group {0}. Expected {1} but got {2}.".format(parent, expected_length, len(children))) + u"Number of children incorrect for group {0}. Expected {1} but got {2}.".format(parent, expected_length, len(children))) # lint-amnesty, pylint: disable=line-too-long for idx, expected in enumerate(expected_ordering.get(parent)): test_class.assertEqual(expected, children[idx].name) blocks_checked.add(expected) diff --git a/common/test/acceptance/pages/studio/video/video.py b/common/test/acceptance/pages/studio/video/video.py index 8f63464281..6b81382db3 100644 --- a/common/test/acceptance/pages/studio/video/video.py +++ b/common/test/acceptance/pages/studio/video/video.py @@ -14,7 +14,7 @@ from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.keys import Keys from six.moves import range -from common.test.acceptance.pages.common.utils import sync_on_notification +from common.test.acceptance.pages.common.utils import sync_on_notification # lint-amnesty, pylint: disable=no-name-in-module from common.test.acceptance.pages.lms.video.video import VideoPage from common.test.acceptance.tests.helpers import YouTubeStubConfig @@ -113,7 +113,7 @@ class VideoComponentPage(VideoPage): ) def get_element_selector(self, class_name, vertical=False): - return super(VideoComponentPage, self).get_element_selector(class_name, vertical=vertical) + return super(VideoComponentPage, self).get_element_selector(class_name, vertical=vertical) # lint-amnesty, pylint: disable=super-with-arguments def _wait_for(self, check_func, desc, result=False, timeout=30): """ @@ -549,7 +549,7 @@ class VideoComponentPage(VideoPage): mime_type = 'application/x-subrip' lang_code = '?language_code={}'.format(language_code) link = [link for link in self.q(css='.download-action').attrs('href') if lang_code in link] - result, headers, content = self._get_transcript(link[0]) + result, headers, content = self._get_transcript(link[0]) # lint-amnesty, pylint: disable=no-member return result is True and mime_type in headers['content-type'] and text_to_search in content.decode('utf-8') @@ -578,7 +578,7 @@ class VideoComponentPage(VideoPage): As all the captions lines are exactly same so only getting partial lines will work. """ - self.wait_for_captions() + self.wait_for_captions() # lint-amnesty, pylint: disable=no-member selector = u'.subtitles li:nth-child({})' return ' '.join([self.q(css=selector.format(i)).text[0] for i in range(1, 6)]) diff --git a/common/test/acceptance/tests/discussion/helpers.py b/common/test/acceptance/tests/discussion/helpers.py index b0d562ecd5..eabcdcae9a 100644 --- a/common/test/acceptance/tests/discussion/helpers.py +++ b/common/test/acceptance/tests/discussion/helpers.py @@ -51,7 +51,7 @@ class CohortTestMixin(object): Sets up the course to use cohorting with the given list of auto_cohort_groups. If auto_cohort_groups is None, no auto cohorts are set. """ - course_fixture._update_xblock(course_fixture._course_location, { + course_fixture._update_xblock(course_fixture._course_location, { # lint-amnesty, pylint: disable=protected-access "metadata": { u"cohort_config": { "auto_cohort_groups": auto_cohort_groups or [], @@ -65,7 +65,7 @@ class CohortTestMixin(object): """ Adds a cohort by name, returning its ID. """ - url = LMS_BASE_URL + "/courses/" + course_fixture._course_key + '/cohorts/' + url = LMS_BASE_URL + "/courses/" + course_fixture._course_key + '/cohorts/' # lint-amnesty, pylint: disable=protected-access data = json.dumps({"name": cohort_name, 'assignment_type': 'manual'}) response = course_fixture.session.post(url, data=data, headers=course_fixture.headers) self.assertTrue(response.ok, "Failed to create cohort") @@ -75,7 +75,7 @@ class CohortTestMixin(object): """ Adds a user to the specified cohort. """ - url = LMS_BASE_URL + "/courses/" + course_fixture._course_key + "/cohorts/{}/add".format(cohort_id) + url = LMS_BASE_URL + "/courses/" + course_fixture._course_key + "/cohorts/{}/add".format(cohort_id) # lint-amnesty, pylint: disable=protected-access data = {"users": username} course_fixture.headers['Content-type'] = 'application/x-www-form-urlencoded' response = course_fixture.session.post(url, data=data, headers=course_fixture.headers) @@ -85,7 +85,7 @@ class CohortTestMixin(object): class BaseDiscussionTestCase(UniqueCourseTest, ForumsConfigMixin): """Base test case class for all discussions-related tests.""" def setUp(self): - super(BaseDiscussionTestCase, self).setUp() + super(BaseDiscussionTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.discussion_id = "test_discussion_{}".format(uuid4().hex) self.course_fixture = CourseFixture(**self.course_info) diff --git a/common/test/acceptance/tests/discussion/test_cohort_management.py b/common/test/acceptance/tests/discussion/test_cohort_management.py index 50e07f97b1..8c408acaed 100644 --- a/common/test/acceptance/tests/discussion/test_cohort_management.py +++ b/common/test/acceptance/tests/discussion/test_cohort_management.py @@ -24,7 +24,7 @@ class CohortConfigurationTest(EventsTestMixin, UniqueCourseTest, CohortTestMixin """ Set up a cohorted course """ - super(CohortConfigurationTest, self).setUp() + super(CohortConfigurationTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # create course with cohorts self.manual_cohort_name = "ManualCohort1" diff --git a/common/test/acceptance/tests/discussion/test_discussion.py b/common/test/acceptance/tests/discussion/test_discussion.py index 0400be395f..b37ae7180a 100644 --- a/common/test/acceptance/tests/discussion/test_discussion.py +++ b/common/test/acceptance/tests/discussion/test_discussion.py @@ -7,7 +7,7 @@ from uuid import uuid4 import pytest -from common.test.acceptance.fixtures.course import CourseFixture, XBlockFixtureDesc +from common.test.acceptance.fixtures.course import CourseFixture, XBlockFixtureDesc # lint-amnesty, pylint: disable=unused-import from common.test.acceptance.fixtures.discussion import ( Comment, Response, @@ -23,7 +23,7 @@ from common.test.acceptance.tests.discussion.helpers import BaseDiscussionMixin, from common.test.acceptance.tests.helpers import UniqueCourseTest from openedx.core.lib.tests import attr -THREAD_CONTENT_WITH_LATEX = u"""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt +THREAD_CONTENT_WITH_LATEX = u"""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt # lint-amnesty, pylint: disable=line-too-long ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit sse cillum dolore eu fugiat nulla pariatur. @@ -94,7 +94,7 @@ class DiscussionHomePageTest(BaseDiscussionTestCase): SEARCHED_USERNAME = "gizmo" def setUp(self): - super(DiscussionHomePageTest, self).setUp() + super(DiscussionHomePageTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments AutoAuthPage(self.browser, course_id=self.course_id).visit() self.page = DiscussionTabHomePage(self.browser, self.course_id) self.page.visit() @@ -117,7 +117,7 @@ class DiscussionTabMultipleThreadTest(BaseDiscussionTestCase, BaseDiscussionMixi Tests for the discussion page with multiple threads """ def setUp(self): - super(DiscussionTabMultipleThreadTest, self).setUp() + super(DiscussionTabMultipleThreadTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments AutoAuthPage(self.browser, course_id=self.course_id).visit() self.thread_count = 2 self.thread_ids = [] @@ -167,15 +167,15 @@ class DiscussionOpenClosedThreadTest(BaseDiscussionTestCase): """ def setUp(self): - super(DiscussionOpenClosedThreadTest, self).setUp() + super(DiscussionOpenClosedThreadTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.thread_id = "test_thread_{}".format(uuid4().hex) - def setup_user(self, roles=[]): + def setup_user(self, roles=[]): # lint-amnesty, pylint: disable=dangerous-default-value roles_str = ','.join(roles) - self.user_id = AutoAuthPage(self.browser, course_id=self.course_id, roles=roles_str).visit().get_user_id() + self.user_id = AutoAuthPage(self.browser, course_id=self.course_id, roles=roles_str).visit().get_user_id() # lint-amnesty, pylint: disable=attribute-defined-outside-init - def setup_view(self, **thread_kwargs): + def setup_view(self, **thread_kwargs): # lint-amnesty, pylint: disable=missing-function-docstring thread_kwargs.update({'commentable_id': self.discussion_id}) view = SingleThreadViewFixture( Thread(id=self.thread_id, **thread_kwargs) @@ -183,7 +183,7 @@ class DiscussionOpenClosedThreadTest(BaseDiscussionTestCase): view.addResponse(Response(id="response1")) view.push() - def setup_openclosed_thread_page(self, closed=False): + def setup_openclosed_thread_page(self, closed=False): # lint-amnesty, pylint: disable=missing-function-docstring self.setup_user(roles=['Moderator']) if closed: self.setup_view(closed=True) @@ -225,11 +225,11 @@ class DiscussionResponseEditTest(BaseDiscussionTestCase): """ Tests for editing responses displayed beneath thread in the single thread view. """ - def setup_user(self, roles=[]): + def setup_user(self, roles=[]): # lint-amnesty, pylint: disable=dangerous-default-value roles_str = ','.join(roles) - self.user_id = AutoAuthPage(self.browser, course_id=self.course_id, roles=roles_str).visit().get_user_id() + self.user_id = AutoAuthPage(self.browser, course_id=self.course_id, roles=roles_str).visit().get_user_id() # lint-amnesty, pylint: disable=attribute-defined-outside-init - def setup_view(self): + def setup_view(self): # lint-amnesty, pylint: disable=missing-function-docstring view = SingleThreadViewFixture(Thread(id="response_edit_test_thread", commentable_id=self.discussion_id)) view.addResponse( Response(id="response_other_author", user_id="other", thread_id="response_edit_test_thread"), @@ -260,15 +260,15 @@ class DiscussionCommentEditTest(BaseDiscussionTestCase): """ Tests for editing comments displayed beneath responses in the single thread view. """ - def setup_user(self, roles=[]): + def setup_user(self, roles=[]): # lint-amnesty, pylint: disable=dangerous-default-value roles_str = ','.join(roles) - self.user_id = AutoAuthPage(self.browser, course_id=self.course_id, roles=roles_str).visit().get_user_id() + self.user_id = AutoAuthPage(self.browser, course_id=self.course_id, roles=roles_str).visit().get_user_id() # lint-amnesty, pylint: disable=attribute-defined-outside-init - def setup_view(self): + def setup_view(self): # lint-amnesty, pylint: disable=missing-function-docstring view = SingleThreadViewFixture(Thread(id="comment_edit_test_thread", commentable_id=self.discussion_id)) view.addResponse( Response(id="response1"), - [Comment(id="comment_other_author", user_id="other"), Comment(id="comment_self_author", user_id=self.user_id)]) + [Comment(id="comment_other_author", user_id="other"), Comment(id="comment_self_author", user_id=self.user_id)]) # lint-amnesty, pylint: disable=line-too-long view.push() @attr('a11y') @@ -321,7 +321,7 @@ class DiscussionSearchAlertTest(UniqueCourseTest): SEARCHED_USERNAME = "gizmo" def setUp(self): - super(DiscussionSearchAlertTest, self).setUp() + super(DiscussionSearchAlertTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments CourseFixture(**self.course_info).install() # first auto auth call sets up a user that we will search for in some tests self.searched_user_id = AutoAuthPage( diff --git a/common/test/acceptance/tests/helpers.py b/common/test/acceptance/tests/helpers.py index 1a4f9312be..de03eef29d 100644 --- a/common/test/acceptance/tests/helpers.py +++ b/common/test/acceptance/tests/helpers.py @@ -19,12 +19,12 @@ from bok_choy.promise import EmptyPromise, Promise from bok_choy.web_app_test import WebAppTest from opaque_keys.edx.locator import CourseLocator from path import Path as path -from pymongo import ASCENDING, MongoClient +from pymongo import ASCENDING, MongoClient # lint-amnesty, pylint: disable=unused-import from selenium.common.exceptions import StaleElementReferenceException from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.select import Select from selenium.webdriver.support.ui import WebDriverWait -from six.moves import range, zip +from six.moves import range, zip # lint-amnesty, pylint: disable=unused-import from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory from common.test.acceptance.fixtures.course import XBlockFixtureDesc @@ -342,7 +342,7 @@ class EventsTestMixin(TestCase): Helpers and setup for running tests that evaluate events emitted """ def setUp(self): - super(EventsTestMixin, self).setUp() + super(EventsTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments mongo_host = 'edx.devstack.mongo' if 'BOK_CHOY_HOSTNAME' in os.environ else 'localhost' self.event_collection = MongoClient(mongo_host)["test"]["events"] self.start_time = datetime.now() @@ -354,14 +354,14 @@ class AcceptanceTest(WebAppTest): """ def __init__(self, *args, **kwargs): - super(AcceptanceTest, self).__init__(*args, **kwargs) + super(AcceptanceTest, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments # Use long messages so that failures show actual and expected values self.longMessage = True # pylint: disable=invalid-name def tearDown(self): self._save_console_log() - super(AcceptanceTest, self).tearDown() + super(AcceptanceTest, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments def _save_console_log(self): """ @@ -411,7 +411,7 @@ class UniqueCourseTest(AcceptanceTest): """ def setUp(self): - super(UniqueCourseTest, self).setUp() + super(UniqueCourseTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_info = { 'org': 'test_org', @@ -440,7 +440,7 @@ class YouTubeConfigError(Exception): """ Error occurred while configuring YouTube Stub Server. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class YouTubeStubConfig(object): diff --git a/common/test/acceptance/tests/lms/test_lms.py b/common/test/acceptance/tests/lms/test_lms.py index 7f7de023f4..e9e502de66 100644 --- a/common/test/acceptance/tests/lms/test_lms.py +++ b/common/test/acceptance/tests/lms/test_lms.py @@ -30,7 +30,7 @@ class CourseWikiA11yTest(UniqueCourseTest): """ Initialize pages and install a course fixture. """ - super(CourseWikiA11yTest, self).setUp() + super(CourseWikiA11yTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # self.course_info['number'] must be shorter since we are accessing the wiki. See TNL-1751 self.course_info['number'] = self.unique_id[0:6] diff --git a/common/test/acceptance/tests/lms/test_lms_course_home.py b/common/test/acceptance/tests/lms/test_lms_course_home.py index a161dbf37a..313d69d961 100644 --- a/common/test/acceptance/tests/lms/test_lms_course_home.py +++ b/common/test/acceptance/tests/lms/test_lms_course_home.py @@ -22,7 +22,7 @@ class CourseHomeBaseTest(UniqueCourseTest): """ Initialize pages and install a course fixture. """ - super(CourseHomeBaseTest, self).setUp() + super(CourseHomeBaseTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_home_page = CourseHomePage(self.browser, self.course_id) self.courseware_page = CoursewarePage(self.browser, self.course_id) diff --git a/common/test/acceptance/tests/lms/test_lms_dashboard.py b/common/test/acceptance/tests/lms/test_lms_dashboard.py index 2f254af733..7a30c52c91 100644 --- a/common/test/acceptance/tests/lms/test_lms_dashboard.py +++ b/common/test/acceptance/tests/lms/test_lms_dashboard.py @@ -23,7 +23,7 @@ class BaseLmsDashboardTestMultiple(UniqueCourseTest): """ # Some parameters are provided by the parent setUp() routine, such as the following: # self.course_id, self.course_info, self.unique_id - super(BaseLmsDashboardTestMultiple, self).setUp() + super(BaseLmsDashboardTestMultiple, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Load page objects for use by the tests self.dashboard_page = DashboardPage(self.browser) diff --git a/common/test/acceptance/tests/lms/test_lms_instructor_dashboard.py b/common/test/acceptance/tests/lms/test_lms_instructor_dashboard.py index 721d7ce82d..1553d96eb3 100644 --- a/common/test/acceptance/tests/lms/test_lms_instructor_dashboard.py +++ b/common/test/acceptance/tests/lms/test_lms_instructor_dashboard.py @@ -59,7 +59,7 @@ class LMSInstructorDashboardA11yTest(BaseInstructorDashboardTest): Instructor dashboard base accessibility test. """ def setUp(self): - super(LMSInstructorDashboardA11yTest, self).setUp() + super(LMSInstructorDashboardA11yTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_fixture = CourseFixture(**self.course_info).install() self.log_in_as_instructor() self.instructor_dashboard_page = self.visit_instructor_dashboard() @@ -82,7 +82,7 @@ class BulkEmailTest(BaseInstructorDashboardTest): shard = 23 def setUp(self): - super(BulkEmailTest, self).setUp() + super(BulkEmailTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_fixture = CourseFixture(**self.course_info).install() self.log_in_as_instructor() instructor_dashboard_page = self.visit_instructor_dashboard() @@ -114,7 +114,7 @@ class AutoEnrollmentWithCSVTest(BaseInstructorDashboardTest): """ def setUp(self): - super(AutoEnrollmentWithCSVTest, self).setUp() + super(AutoEnrollmentWithCSVTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_fixture = CourseFixture(**self.course_info).install() self.log_in_as_instructor() instructor_dashboard_page = self.visit_instructor_dashboard() @@ -141,7 +141,7 @@ class CertificatesTest(BaseInstructorDashboardTest): """ def setUp(self): - super(CertificatesTest, self).setUp() + super(CertificatesTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_certificate_config = { 'id': 1, 'name': 'Certificate name', @@ -194,7 +194,7 @@ class CertificateInvalidationTest(BaseInstructorDashboardTest): ).install() def setUp(self): - super(CertificateInvalidationTest, self).setUp() + super(CertificateInvalidationTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # set same course number as we have in fixture json self.course_info['number'] = "335535897951379478207964576572017930000" diff --git a/common/test/acceptance/tests/lms/test_lms_problems.py b/common/test/acceptance/tests/lms/test_lms_problems.py index 6e49713deb..2220dbd4a5 100644 --- a/common/test/acceptance/tests/lms/test_lms_problems.py +++ b/common/test/acceptance/tests/lms/test_lms_problems.py @@ -20,7 +20,7 @@ class ProblemsTest(UniqueCourseTest): """ def setUp(self): - super(ProblemsTest, self).setUp() + super(ProblemsTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.username = "test_student_{uuid}".format(uuid=self.unique_id[0:8]) self.email = "{username}@example.com".format(username=self.username) diff --git a/common/test/acceptance/tests/lms/test_lms_user_preview.py b/common/test/acceptance/tests/lms/test_lms_user_preview.py index b2107eeb62..d69f58067c 100644 --- a/common/test/acceptance/tests/lms/test_lms_user_preview.py +++ b/common/test/acceptance/tests/lms/test_lms_user_preview.py @@ -24,7 +24,7 @@ class StaffViewTest(UniqueCourseTest): EMAIL = "johndoe@example.com" def setUp(self): - super(StaffViewTest, self).setUp() + super(StaffViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.courseware_page = CoursewarePage(self.browser, self.course_id) @@ -60,7 +60,7 @@ class CourseWithContentGroupsTest(StaffViewTest): """ def setUp(self): - super(CourseWithContentGroupsTest, self).setUp() + super(CourseWithContentGroupsTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # pylint: disable=protected-access self.course_fixture._update_xblock(self.course_fixture._course_location, { "metadata": { @@ -96,10 +96,10 @@ class CourseWithContentGroupsTest(StaffViewTest): """) - self.alpha_text = "VISIBLE TO ALPHA" - self.beta_text = "VISIBLE TO BETA" - self.audit_text = "VISIBLE TO AUDIT" - self.everyone_text = "VISIBLE TO EVERYONE" + self.alpha_text = "VISIBLE TO ALPHA" # lint-amnesty, pylint: disable=attribute-defined-outside-init + self.beta_text = "VISIBLE TO BETA" # lint-amnesty, pylint: disable=attribute-defined-outside-init + self.audit_text = "VISIBLE TO AUDIT" # lint-amnesty, pylint: disable=attribute-defined-outside-init + self.everyone_text = "VISIBLE TO EVERYONE" # lint-amnesty, pylint: disable=attribute-defined-outside-init course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( diff --git a/common/test/acceptance/tests/lms/test_problem_types.py b/common/test/acceptance/tests/lms/test_problem_types.py index 9958b7b482..2195955732 100644 --- a/common/test/acceptance/tests/lms/test_problem_types.py +++ b/common/test/acceptance/tests/lms/test_problem_types.py @@ -57,7 +57,7 @@ class ProblemTypeTestBaseMeta(ABCMeta): if obj.__getattribute__(required_attr) is None: raise NotImplementedError(msg) except AttributeError: - raise NotImplementedError(msg) + raise NotImplementedError(msg) # lint-amnesty, pylint: disable=raise-missing-from return obj @@ -96,7 +96,7 @@ class ProblemTypeTestBase(six.with_metaclass(ProblemTypeTestBaseMeta, ProblemsTe """ Visits courseware_page and defines self.problem_page. """ - super(ProblemTypeTestBase, self).setUp() + super(ProblemTypeTestBase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.courseware_page.visit() self.problem_page = ProblemPage(self.browser) @@ -215,7 +215,7 @@ class AnnotationProblemTypeBase(ProblemTypeTestBase): """ Additional setup for AnnotationProblemTypeBase """ - super(AnnotationProblemTypeBase, self).setUp(*args, **kwargs) + super(AnnotationProblemTypeBase, self).setUp(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.problem_page.a11y_audit.config.set_rules({ "ignore": [ @@ -247,7 +247,7 @@ class AnnotationProblemTypeTest(AnnotationProblemTypeBase, ProblemTypeA11yTestMi Standard tests for the Annotation Problem Type """ shard = 20 - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class CheckboxProblemTypeBase(ProblemTypeTestBase): @@ -445,7 +445,7 @@ class RadioProblemTypeTest(RadioProblemTypeBase, ProblemTypeA11yTestMixin): Standard tests for the Multiple Radio Problem Type """ shard = 24 - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class RadioProblemTypeTestNonRandomized(RadioProblemTypeBase, ProblemTypeA11yTestMixin): @@ -500,7 +500,7 @@ class DropdownProblemTypeTest(DropDownProblemTypeBase, ProblemTypeA11yTestMixin) Standard tests for the Dropdown Problem Type """ shard = 8 - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass @ddt.ddt @@ -569,7 +569,7 @@ class StringProblemTypeBase(ProblemTypeTestBase): Answer string problem. """ textvalue = 'correct string' if correctness == 'correct' else 'incorrect string' - self.problem_page.fill_answer(textvalue) + self.problem_page.fill_answer(textvalue) # lint-amnesty, pylint: disable=no-member class StringProblemTypeTest(StringProblemTypeBase, ProblemTypeA11yTestMixin): @@ -577,7 +577,7 @@ class StringProblemTypeTest(StringProblemTypeBase, ProblemTypeA11yTestMixin): Standard tests for the String Problem Type """ shard = 8 - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class NumericalProblemTypeBase(ProblemTypeTestBase): @@ -633,7 +633,7 @@ class NumericalProblemTypeBase(ProblemTypeTestBase): textvalue = 'notNum' else: textvalue = str(random.randint(-2, 2)) - self.problem_page.fill_answer(textvalue) + self.problem_page.fill_answer(textvalue) # lint-amnesty, pylint: disable=no-member @ddt.ddt @@ -713,7 +713,7 @@ class FormulaProblemTypeBase(ProblemTypeTestBase): Answer formula problem. """ textvalue = "x^2+2*x+y" if correctness == 'correct' else 'x^2' - self.problem_page.fill_answer(textvalue) + self.problem_page.fill_answer(textvalue) # lint-amnesty, pylint: disable=no-member @ddt.ddt @@ -781,8 +781,8 @@ class ScriptProblemTypeBase(ProblemTypeTestBase): if not correctness == 'correct': second_addend += random.randint(1, 10) - self.problem_page.fill_answer(first_addend, input_num=0) - self.problem_page.fill_answer(second_addend, input_num=1) + self.problem_page.fill_answer(first_addend, input_num=0) # lint-amnesty, pylint: disable=no-member + self.problem_page.fill_answer(second_addend, input_num=1) # lint-amnesty, pylint: disable=no-member @ddt.ddt @@ -791,7 +791,7 @@ class ScriptProblemTypeTest(ScriptProblemTypeBase, ProblemTypeA11yTestMixin): Standard tests for the Script Problem Type """ shard = 20 - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class ScriptProblemTypeTestNonRandomized(ScriptProblemTypeBase, ProblemTypeA11yTestMixin): @@ -871,7 +871,7 @@ class CodeProblemTypeBase(ProblemTypeTestBase): # (there's not