diff --git a/cms/djangoapps/api/__init__.py b/cms/djangoapps/api/__init__.py index 2046a6c208..fd876356d9 100644 --- a/cms/djangoapps/api/__init__.py +++ b/cms/djangoapps/api/__init__.py @@ -1,2 +1,2 @@ -# pylint: disable=missing-module-docstring +# lint-amnesty, pylint: disable=django-not-configured, missing-module-docstring default_app_config = 'cms.djangoapps.api.apps.ApiConfig' diff --git a/cms/djangoapps/api/v1/serializers/course_runs.py b/cms/djangoapps/api/v1/serializers/course_runs.py index 2579a6cdee..8bd97eac4f 100644 --- a/cms/djangoapps/api/v1/serializers/course_runs.py +++ b/cms/djangoapps/api/v1/serializers/course_runs.py @@ -26,7 +26,7 @@ User = get_user_model() log = logging.getLogger(__name__) -class CourseAccessRoleSerializer(serializers.ModelSerializer): +class CourseAccessRoleSerializer(serializers.ModelSerializer): # lint-amnesty, pylint: disable=missing-class-docstring user = serializers.SlugRelatedField(slug_field='username', queryset=User.objects.all()) class Meta: @@ -34,21 +34,21 @@ class CourseAccessRoleSerializer(serializers.ModelSerializer): fields = ('user', 'role',) -class CourseRunScheduleSerializer(serializers.Serializer): +class CourseRunScheduleSerializer(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method start = serializers.DateTimeField() end = serializers.DateTimeField() enrollment_start = serializers.DateTimeField(allow_null=True, required=False) enrollment_end = serializers.DateTimeField(allow_null=True, required=False) -class CourseRunTeamSerializer(serializers.Serializer): +class CourseRunTeamSerializer(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring def to_internal_value(self, data): """Overriding this to support deserialization, for write operations.""" for member in data: try: User.objects.get(username=member['user']) except User.DoesNotExist: - raise serializers.ValidationError( + raise serializers.ValidationError( # lint-amnesty, pylint: disable=raise-missing-from _('Course team user does not exist') ) @@ -64,10 +64,10 @@ class CourseRunTeamSerializer(serializers.Serializer): return instance -class CourseRunTeamSerializerMixin(serializers.Serializer): +class CourseRunTeamSerializerMixin(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring team = CourseRunTeamSerializer(required=False) - def update_team(self, instance, team): + def update_team(self, instance, team): # lint-amnesty, pylint: disable=missing-function-docstring # Existing data should remain intact when performing a partial update. if not self.partial: CourseAccessRole.objects.filter(course_id=instance.id).delete() @@ -91,7 +91,7 @@ def image_is_jpeg_or_png(value): u'Only JPEG and PNG image types are supported. {} is not valid'.format(content_type)) -class CourseRunImageField(serializers.ImageField): +class CourseRunImageField(serializers.ImageField): # lint-amnesty, pylint: disable=missing-class-docstring default_validators = [image_is_jpeg_or_png] def get_attribute(self, instance): @@ -103,7 +103,7 @@ class CourseRunImageField(serializers.ImageField): return request.build_absolute_uri(value) -class CourseRunPacingTypeField(serializers.ChoiceField): +class CourseRunPacingTypeField(serializers.ChoiceField): # lint-amnesty, pylint: disable=missing-class-docstring def to_representation(self, value): return 'self_paced' if value else 'instructor_paced' @@ -111,7 +111,7 @@ class CourseRunPacingTypeField(serializers.ChoiceField): return data == 'self_paced' -class CourseRunImageSerializer(serializers.Serializer): +class CourseRunImageSerializer(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring # We set an empty default to prevent the parent serializer from attempting # to save this value to the Course object. card_image = CourseRunImageField(source='course_image', default=empty) @@ -126,13 +126,13 @@ class CourseRunImageSerializer(serializers.Serializer): return instance -class CourseRunSerializerCommonFieldsMixin(serializers.Serializer): +class CourseRunSerializerCommonFieldsMixin(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method schedule = CourseRunScheduleSerializer(source='*', required=False) pacing_type = CourseRunPacingTypeField(source='self_paced', required=False, choices=((False, 'instructor_paced'), (True, 'self_paced'),)) -class CourseRunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTeamSerializerMixin, serializers.Serializer): +class CourseRunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTeamSerializerMixin, serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring id = serializers.CharField(read_only=True) title = serializers.CharField(source='display_name') images = CourseRunImageSerializer(source='*', required=False) @@ -150,7 +150,7 @@ class CourseRunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTeamSer return instance -class CourseRunCreateSerializer(CourseRunSerializer): +class CourseRunCreateSerializer(CourseRunSerializer): # lint-amnesty, pylint: disable=missing-class-docstring org = serializers.CharField(source='id.org') number = serializers.CharField(source='id.course') run = serializers.CharField(source='id.run') @@ -166,7 +166,7 @@ class CourseRunCreateSerializer(CourseRunSerializer): return instance -class CourseRunRerunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTeamSerializerMixin, +class CourseRunRerunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTeamSerializerMixin, # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring serializers.Serializer): title = serializers.CharField(source='display_name', required=False) number = serializers.CharField(source='id.course', required=False) @@ -182,7 +182,7 @@ class CourseRunRerunSerializer(CourseRunSerializerCommonFieldsMixin, CourseRunTe with store.default_store('split'): new_course_run_key = store.make_course_key(course_run_key.org, number, run) except InvalidKeyError: - raise serializers.ValidationError( + raise serializers.ValidationError( # lint-amnesty, pylint: disable=raise-missing-from u'Invalid key supplied. Ensure there are no special characters in the Course Number.' ) if store.has_course(new_course_run_key, ignore_case=True): diff --git a/cms/djangoapps/api/v1/tests/test_serializers/test_course_runs.py b/cms/djangoapps/api/v1/tests/test_serializers/test_course_runs.py index b37c067939..3a6dbb1f6f 100644 --- a/cms/djangoapps/api/v1/tests/test_serializers/test_course_runs.py +++ b/cms/djangoapps/api/v1/tests/test_serializers/test_course_runs.py @@ -18,10 +18,10 @@ from ..utils import serialize_datetime @ddt.ddt -class CourseRunSerializerTests(ModuleStoreTestCase): +class CourseRunSerializerTests(ModuleStoreTestCase): # lint-amnesty, pylint: disable=missing-class-docstring def setUp(self): - super(CourseRunSerializerTests, self).setUp() + super(CourseRunSerializerTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_start = datetime.datetime.now(pytz.UTC) self.course_end = self.course_start + datetime.timedelta(days=30) diff --git a/cms/djangoapps/api/v1/tests/test_views/test_course_runs.py b/cms/djangoapps/api/v1/tests/test_views/test_course_runs.py index 7b2cc67242..5d98818c04 100644 --- a/cms/djangoapps/api/v1/tests/test_views/test_course_runs.py +++ b/cms/djangoapps/api/v1/tests/test_views/test_course_runs.py @@ -8,7 +8,7 @@ import pytz from django.core.files.uploadedfile import SimpleUploadedFile from django.test import RequestFactory, override_settings from django.urls import reverse -from mock import patch +from mock import patch # lint-amnesty, pylint: disable=unused-import from opaque_keys.edx.keys import CourseKey from organizations.api import add_organization, get_course_organizations from rest_framework.test import APIClient @@ -35,7 +35,7 @@ class CourseRunViewSetTests(ModuleStoreTestCase): list_url = reverse('api:v1:course_run-list') def setUp(self): - super(CourseRunViewSetTests, self).setUp() + super(CourseRunViewSetTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.client = APIClient() user = AdminFactory() self.client.login(username=user.username, password=TEST_PASSWORD) @@ -331,7 +331,7 @@ class CourseRunViewSetTests(ModuleStoreTestCase): original_course_run = ToyCourseFactory() add_organization({ 'name': 'Test Organization', - 'short_name': original_course_run.id.org, + 'short_name': original_course_run.id.org, # lint-amnesty, pylint: disable=no-member 'description': 'Testing Organization Description', }) start = datetime.datetime.now(pytz.UTC).replace(microsecond=0) @@ -339,7 +339,7 @@ class CourseRunViewSetTests(ModuleStoreTestCase): user = UserFactory() role = 'instructor' run = '3T2017' - url = reverse('api:v1:course_run-rerun', kwargs={'pk': str(original_course_run.id)}) + url = reverse('api:v1:course_run-rerun', kwargs={'pk': str(original_course_run.id)}) # lint-amnesty, pylint: disable=no-member data = { 'run': run, 'schedule': { @@ -369,16 +369,16 @@ class CourseRunViewSetTests(ModuleStoreTestCase): if number: assert course_run.id.course == number - assert course_run.id.course != original_course_run.id.course + assert course_run.id.course != original_course_run.id.course # lint-amnesty, pylint: disable=no-member else: - assert course_run.id.course == original_course_run.id.course + assert course_run.id.course == original_course_run.id.course # lint-amnesty, pylint: disable=no-member self.assert_course_run_schedule(course_run, start, end) self.assert_access_role(course_run, user, role) self.assert_course_access_role_count(course_run, 1) course_orgs = get_course_organizations(course_run_key) self.assertEqual(len(course_orgs), 1) - self.assertEqual(course_orgs[0]['short_name'], original_course_run.id.org) + self.assertEqual(course_orgs[0]['short_name'], original_course_run.id.org) # lint-amnesty, pylint: disable=no-member def test_rerun_duplicate_run(self): course_run = ToyCourseFactory() diff --git a/cms/djangoapps/api/v1/tests/utils.py b/cms/djangoapps/api/v1/tests/utils.py index 750c1a5a27..1684e018dd 100644 --- a/cms/djangoapps/api/v1/tests/utils.py +++ b/cms/djangoapps/api/v1/tests/utils.py @@ -1,2 +1,3 @@ +# lint-amnesty, pylint: disable=missing-module-docstring def serialize_datetime(d): return d.strftime('%Y-%m-%dT%H:%M:%S.%fZ') diff --git a/cms/djangoapps/api/v1/views/course_runs.py b/cms/djangoapps/api/v1/views/course_runs.py index 9718251382..ebe1b63777 100644 --- a/cms/djangoapps/api/v1/views/course_runs.py +++ b/cms/djangoapps/api/v1/views/course_runs.py @@ -20,7 +20,7 @@ from ..serializers.course_runs import ( ) -class CourseRunViewSet(viewsets.GenericViewSet): +class CourseRunViewSet(viewsets.GenericViewSet): # lint-amnesty, pylint: disable=missing-class-docstring authentication_classes = (JwtAuthentication, SessionAuthentication,) lookup_value_regex = settings.COURSE_KEY_REGEX permission_classes = (permissions.IsAdminUser,) @@ -43,18 +43,18 @@ class CourseRunViewSet(viewsets.GenericViewSet): raise Http404 - def list(self, request, *args, **kwargs): + def list(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument course_runs, __ = _accessible_courses_iter(request) page = self.paginate_queryset(list(course_runs)) serializer = self.get_serializer(page, many=True) return self.get_paginated_response(serializer.data) - def retrieve(self, request, *args, **kwargs): + def retrieve(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument course_run = self.get_object() serializer = self.get_serializer(course_run) return Response(serializer.data) - def update(self, request, *args, **kwargs): + def update(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=missing-function-docstring, unused-argument course_run = self.get_object() partial = kwargs.pop('partial', False) @@ -67,7 +67,7 @@ class CourseRunViewSet(viewsets.GenericViewSet): kwargs['partial'] = True return self.update(request, *args, **kwargs) - def create(self, request, *args, **kwargs): + def create(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument serializer = CourseRunCreateSerializer(data=request.data, context=self.get_serializer_context()) serializer.is_valid(raise_exception=True) serializer.save() @@ -78,7 +78,7 @@ class CourseRunViewSet(viewsets.GenericViewSet): methods=['post', 'put'], parser_classes=(parsers.FormParser, parsers.MultiPartParser,), serializer_class=CourseRunImageSerializer) - def images(self, request, *args, **kwargs): + def images(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=missing-function-docstring, unused-argument course_run = self.get_object() serializer = CourseRunImageSerializer(course_run, data=request.data, context=self.get_serializer_context()) serializer.is_valid(raise_exception=True) @@ -86,7 +86,7 @@ class CourseRunViewSet(viewsets.GenericViewSet): return Response(serializer.data) @action(detail=True, methods=['post']) - def rerun(self, request, *args, **kwargs): + def rerun(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=missing-function-docstring, unused-argument course_run = self.get_object() serializer = CourseRunRerunSerializer(course_run, data=request.data, context=self.get_serializer_context()) serializer.is_valid(raise_exception=True) diff --git a/cms/djangoapps/cms_user_tasks/tests.py b/cms/djangoapps/cms_user_tasks/tests.py index 7eac8b1951..7015b7b4e2 100644 --- a/cms/djangoapps/cms_user_tasks/tests.py +++ b/cms/djangoapps/cms_user_tasks/tests.py @@ -9,7 +9,7 @@ from uuid import uuid4 import mock from boto.exception import NoAuthHandlerFound 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 import mail from django.test import override_settings from django.urls import reverse @@ -72,7 +72,7 @@ class TestUserTasks(APITestCase): """ @classmethod - def setUpTestData(cls): + def setUpTestData(cls): # lint-amnesty, pylint: disable=super-method-not-called cls.user = User.objects.create_user('test_user', 'test@example.com', 'password') cls.status = UserTaskStatus.objects.create( user=cls.user, task_id=str(uuid4()), task_class='test_rest_api.sample_task', name='SampleTask 2', @@ -80,7 +80,7 @@ class TestUserTasks(APITestCase): cls.artifact = UserTaskArtifact.objects.create(status=cls.status, text='Lorem ipsum') def setUp(self): - super(TestUserTasks, self).setUp() + super(TestUserTasks, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.status.refresh_from_db() self.client.force_authenticate(self.user) # pylint: disable=no-member @@ -145,14 +145,14 @@ class TestUserTaskStopped(APITestCase): """ @classmethod - def setUpTestData(cls): + def setUpTestData(cls): # lint-amnesty, pylint: disable=super-method-not-called cls.user = User.objects.create_user('test_user', 'test@example.com', 'password') cls.status = UserTaskStatus.objects.create( user=cls.user, task_id=str(uuid4()), task_class='test_rest_api.sample_task', name='SampleTask 2', total_steps=5) def setUp(self): - super(TestUserTaskStopped, self).setUp() + super(TestUserTaskStopped, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.status.refresh_from_db() self.client.force_authenticate(self.user) # pylint: disable=no-member diff --git a/cms/djangoapps/contentstore/api/views/course_import.py b/cms/djangoapps/contentstore/api/views/course_import.py index 2d94d951f7..9430aee2cd 100644 --- a/cms/djangoapps/contentstore/api/views/course_import.py +++ b/cms/djangoapps/contentstore/api/views/course_import.py @@ -35,7 +35,7 @@ class CourseImportExportViewMixin(DeveloperErrorViewMixin): """ Ensures that the user is authenticated (e.g. not an AnonymousUser) """ - super(CourseImportExportViewMixin, self).perform_authentication(request) + super(CourseImportExportViewMixin, self).perform_authentication(request) # lint-amnesty, pylint: disable=super-with-arguments if request.user.is_anonymous: raise AuthenticationFailed diff --git a/cms/djangoapps/contentstore/api/views/course_quality.py b/cms/djangoapps/contentstore/api/views/course_quality.py index 51ee50234b..998bc828c5 100644 --- a/cms/djangoapps/contentstore/api/views/course_quality.py +++ b/cms/djangoapps/contentstore/api/views/course_quality.py @@ -1,3 +1,4 @@ +# lint-amnesty, pylint: disable=missing-module-docstring import logging import time @@ -128,7 +129,7 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView): return Response(response) - def _required_course_depth(self, request, all_requested): + def _required_course_depth(self, request, all_requested): # lint-amnesty, pylint: disable=missing-function-docstring if get_bool_param(request, 'units', all_requested): # The num_blocks metric for "units" requires retrieving all blocks in the graph. return None @@ -151,7 +152,7 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView): highlights_enabled=highlights_setting.is_enabled(), ) - def _subsections_quality(self, course, request): + def _subsections_quality(self, course, request): # lint-amnesty, pylint: disable=missing-function-docstring subsection_unit_dict = self._get_subsections_and_units(course, request) num_block_types_per_subsection_dict = {} for subsection_key, unit_dict in six.iteritems(subsection_unit_dict): @@ -167,7 +168,7 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView): num_block_types=self._stats_dict(list(six.itervalues(num_block_types_per_subsection_dict))), ) - def _units_quality(self, course, request): + def _units_quality(self, course, request): # lint-amnesty, pylint: disable=missing-function-docstring subsection_unit_dict = self._get_subsections_and_units(course, request) num_leaf_blocks_per_unit = [ unit_info['num_leaf_blocks'] @@ -179,7 +180,7 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView): num_blocks=self._stats_dict(num_leaf_blocks_per_unit), ) - def _videos_quality(self, course): + def _videos_quality(self, course): # lint-amnesty, pylint: disable=missing-function-docstring video_blocks_in_course = modulestore().get_items(course.id, qualifiers={'category': 'video'}) videos, __ = get_videos_for_course(course.id) videos_in_val = list(videos) @@ -227,7 +228,7 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView): return cls._get_all_children(course) @classmethod - def _get_all_children(cls, parent): + def _get_all_children(cls, parent): # lint-amnesty, pylint: disable=missing-function-docstring store = modulestore() children = [store.get_item(child_usage_key) for child_usage_key in cls._get_children(parent)] visible_children = [ @@ -242,14 +243,14 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView): return visible_chidren @classmethod - def _get_children(cls, parent): + def _get_children(cls, parent): # lint-amnesty, pylint: disable=missing-function-docstring if not hasattr(parent, 'children'): return [] else: return parent.children @classmethod - def _get_leaf_blocks(cls, unit): + def _get_leaf_blocks(cls, unit): # lint-amnesty, pylint: disable=missing-function-docstring def leaf_filter(block): return ( block.location.block_type not in ('chapter', 'sequential', 'vertical') and @@ -257,11 +258,11 @@ class CourseQualityView(DeveloperErrorViewMixin, GenericAPIView): ) return [ - block for block in + block for block in # lint-amnesty, pylint: disable=unnecessary-comprehension traverse_pre_order(unit, cls._get_visible_children, leaf_filter) ] - def _stats_dict(self, data): + def _stats_dict(self, data): # lint-amnesty, pylint: disable=missing-function-docstring if not data: return dict( min=None, diff --git a/cms/djangoapps/contentstore/api/views/course_validation.py b/cms/djangoapps/contentstore/api/views/course_validation.py index 12d85e27f2..a04b022288 100644 --- a/cms/djangoapps/contentstore/api/views/course_validation.py +++ b/cms/djangoapps/contentstore/api/views/course_validation.py @@ -1,3 +1,4 @@ +# lint-amnesty, pylint: disable=missing-module-docstring import logging import dateutil @@ -110,7 +111,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView): has_end_date=course.end is not None, ) - def _assignments_validation(self, course, request): + def _assignments_validation(self, course, request): # lint-amnesty, pylint: disable=missing-function-docstring assignments, visible_assignments = self._get_assignments(course) assignments_with_dates = [ a for a in visible_assignments if a.due @@ -218,7 +219,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView): has_update=len(updates) > 0, ) - def _get_assignments(self, course): + def _get_assignments(self, course): # lint-amnesty, pylint: disable=missing-function-docstring store = modulestore() sections = [store.get_item(section_usage_key) for section_usage_key in course.children] assignments = [ @@ -245,7 +246,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView): oras = modulestore().get_items(course.id, qualifiers={'category': 'openassessment'}) return oras if not graded_only else [ora for ora in oras if ora.graded] - def _has_date_before_start(self, ora, start): + def _has_date_before_start(self, ora, start): # lint-amnesty, pylint: disable=missing-function-docstring if ora.submission_start: if dateutil.parser.parse(ora.submission_start).replace(tzinfo=UTC) < start: return True @@ -262,7 +263,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView): return False - def _has_date_after_end(self, ora, end): + def _has_date_after_end(self, ora, end): # lint-amnesty, pylint: disable=missing-function-docstring if ora.submission_start: if dateutil.parser.parse(ora.submission_start).replace(tzinfo=UTC) > end: return True @@ -281,7 +282,7 @@ class CourseValidationView(DeveloperErrorViewMixin, GenericAPIView): def _has_start_date(self, course): return not course.start_date_is_still_default - def _has_grading_policy(self, course): + def _has_grading_policy(self, course): # lint-amnesty, pylint: disable=missing-function-docstring grading_policy_formatted = {} default_grading_policy_formatted = {} diff --git a/cms/djangoapps/contentstore/course_group_config.py b/cms/djangoapps/contentstore/course_group_config.py index bea95bc619..a9ae47aecf 100644 --- a/cms/djangoapps/contentstore/course_group_config.py +++ b/cms/djangoapps/contentstore/course_group_config.py @@ -36,7 +36,7 @@ class GroupConfigurationsValidationError(Exception): """ An error thrown when a group configurations input is invalid. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class GroupConfiguration(object): @@ -62,7 +62,7 @@ class GroupConfiguration(object): try: configuration = json.loads(json_string.decode("utf-8")) except ValueError: - raise GroupConfigurationsValidationError(_("invalid JSON")) + raise GroupConfigurationsValidationError(_("invalid JSON")) # lint-amnesty, pylint: disable=raise-missing-from configuration["version"] = UserPartition.VERSION return configuration @@ -102,7 +102,7 @@ class GroupConfiguration(object): """ Return a list of IDs that already in use. """ - return set([p.id for p in get_all_partitions_for_course(course)]) + return set([p.id for p in get_all_partitions_for_course(course)]) # lint-amnesty, pylint: disable=consider-using-set-comprehension def get_user_partition(self): """ @@ -111,7 +111,7 @@ class GroupConfiguration(object): try: return UserPartition.from_json(self.configuration) except ReadOnlyUserPartitionError: - raise GroupConfigurationsValidationError(_("unable to load this type of group configuration")) + raise GroupConfigurationsValidationError(_("unable to load this type of group configuration")) # lint-amnesty, pylint: disable=raise-missing-from @staticmethod def _get_usage_dict(course, unit, item, scheme_name=None): diff --git a/cms/djangoapps/contentstore/courseware_index.py b/cms/djangoapps/contentstore/courseware_index.py index ccb472fcea..e6b465797a 100644 --- a/cms/djangoapps/contentstore/courseware_index.py +++ b/cms/djangoapps/contentstore/courseware_index.py @@ -57,7 +57,7 @@ class SearchIndexingError(Exception): """ Indicates some error(s) occured during indexing """ def __init__(self, message, error_list): - super(SearchIndexingError, self).__init__(message) + super(SearchIndexingError, self).__init__(message) # lint-amnesty, pylint: disable=super-with-arguments self.error_list = error_list @@ -116,7 +116,7 @@ class SearchIndexerBase(object, metaclass=ABCMeta): searcher.remove(result_ids) @classmethod - def index(cls, modulestore, structure_key, triggered_at=None, reindex_age=REINDEX_AGE, timeout=INDEXING_REQUEST_TIMEOUT): + def index(cls, modulestore, structure_key, triggered_at=None, reindex_age=REINDEX_AGE, timeout=INDEXING_REQUEST_TIMEOUT): # lint-amnesty, pylint: disable=line-too-long, too-many-statements """ Process course for indexing @@ -187,7 +187,7 @@ class SearchIndexerBase(object, metaclass=ABCMeta): item_content_groups = None - if item.category == "split_test": + if item.category == "split_test": # lint-amnesty, pylint: disable=too-many-nested-blocks split_partition = item.get_selected_partition() for split_test_child in item.get_children(): if split_partition: @@ -327,7 +327,7 @@ class SearchIndexerBase(object, metaclass=ABCMeta): Returns: None """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass @classmethod def supplemental_fields(cls, item): # pylint: disable=unused-argument @@ -667,7 +667,7 @@ class CourseAboutSearchIndexer(CoursewareSearchIndexer): return {"course": text_type(normalized_structure_key), "org": normalized_structure_key.org} @classmethod - def remove_deleted_items(cls, structure_key): + def remove_deleted_items(cls, structure_key): # lint-amnesty, pylint: disable=arguments-differ """ Remove item from Course About Search_index """ searcher = SearchEngine.get_search_engine(cls.INDEX_NAME) if not searcher: diff --git a/cms/djangoapps/contentstore/debug_file_uploader.py b/cms/djangoapps/contentstore/debug_file_uploader.py index 39d18cefe8..77cbc59b71 100644 --- a/cms/djangoapps/contentstore/debug_file_uploader.py +++ b/cms/djangoapps/contentstore/debug_file_uploader.py @@ -6,9 +6,9 @@ import time from django.core.files.uploadhandler import FileUploadHandler -class DebugFileUploader(FileUploadHandler): +class DebugFileUploader(FileUploadHandler): # lint-amnesty, pylint: disable=missing-class-docstring def __init__(self, request=None): - super(DebugFileUploader, self).__init__(request) + super(DebugFileUploader, self).__init__(request) # lint-amnesty, pylint: disable=super-with-arguments self.count = 0 def receive_data_chunk(self, raw_data, start): diff --git a/cms/djangoapps/contentstore/git_export_utils.py b/cms/djangoapps/contentstore/git_export_utils.py index 07c46322dd..470d3ac27c 100644 --- a/cms/djangoapps/contentstore/git_export_utils.py +++ b/cms/djangoapps/contentstore/git_export_utils.py @@ -10,7 +10,7 @@ import subprocess 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.utils import timezone from django.utils.translation import ugettext_lazy as _ from six.moves.urllib.parse import urlparse @@ -34,7 +34,7 @@ class GitExportError(Exception): def __init__(self, message): # Force the lazy i18n values to turn into actual unicode objects - super(GitExportError, self).__init__(six.text_type(message)) + super(GitExportError, self).__init__(six.text_type(message)) # lint-amnesty, pylint: disable=super-with-arguments NO_EXPORT_DIR = _(u"GIT_REPO_EXPORT_DIR not set or path {0} doesn't exist, " "please create it, or configure a different path with " @@ -110,7 +110,7 @@ def export_to_git(course_id, repo, user='', rdir=None): branch = cmd_log(cmd, cwd).decode('utf-8').strip('\n') except subprocess.CalledProcessError as ex: log.exception(u'Failed to get branch: %r', ex.output) - raise GitExportError(GitExportError.DETACHED_HEAD) + raise GitExportError(GitExportError.DETACHED_HEAD) # lint-amnesty, pylint: disable=raise-missing-from cmds = [ ['git', 'remote', 'set-url', 'origin', repo], @@ -129,7 +129,7 @@ def export_to_git(course_id, repo, user='', rdir=None): cmd_log(cmd, cwd) except subprocess.CalledProcessError as ex: log.exception(u'Failed to pull git repository: %r', ex.output) - raise GitExportError(GitExportError.CANNOT_PULL) + raise GitExportError(GitExportError.CANNOT_PULL) # lint-amnesty, pylint: disable=raise-missing-from # export course as xml before commiting and pushing root_dir = os.path.dirname(rdirp) @@ -139,7 +139,7 @@ def export_to_git(course_id, repo, user='', rdir=None): root_dir, course_dir) except (EnvironmentError, AttributeError): log.exception('Failed export to xml') - raise GitExportError(GitExportError.XML_EXPORT_FAIL) + raise GitExportError(GitExportError.XML_EXPORT_FAIL) # lint-amnesty, pylint: disable=raise-missing-from # Get current branch if not already set if not branch: @@ -149,7 +149,7 @@ def export_to_git(course_id, repo, user='', rdir=None): except subprocess.CalledProcessError as ex: log.exception(u'Failed to get branch from freshly cloned repo: %r', ex.output) - raise GitExportError(GitExportError.MISSING_BRANCH) + raise GitExportError(GitExportError.MISSING_BRANCH) # lint-amnesty, pylint: disable=raise-missing-from # Now that we have fresh xml exported, set identity, add # everything to git, commit, and push to the right branch. @@ -171,15 +171,15 @@ def export_to_git(course_id, repo, user='', rdir=None): cmd_log(['git', 'config', 'user.name', ident['name']], cwd) except subprocess.CalledProcessError as ex: log.exception(u'Error running git configure commands: %r', ex.output) - raise GitExportError(GitExportError.CONFIG_ERROR) + raise GitExportError(GitExportError.CONFIG_ERROR) # lint-amnesty, pylint: disable=raise-missing-from try: cmd_log(['git', 'add', '.'], cwd) cmd_log(['git', 'commit', '-a', '-m', commit_msg], cwd) except subprocess.CalledProcessError as ex: log.exception(u'Unable to commit changes: %r', ex.output) - raise GitExportError(GitExportError.CANNOT_COMMIT) + raise GitExportError(GitExportError.CANNOT_COMMIT) # lint-amnesty, pylint: disable=raise-missing-from try: cmd_log(['git', 'push', '-q', 'origin', branch], cwd) except subprocess.CalledProcessError as ex: log.exception(u'Error running git push command: %r', ex.output) - raise GitExportError(GitExportError.CANNOT_PUSH) + raise GitExportError(GitExportError.CANNOT_PUSH) # lint-amnesty, pylint: disable=raise-missing-from diff --git a/cms/djangoapps/contentstore/management/commands/cleanup_assets.py b/cms/djangoapps/contentstore/management/commands/cleanup_assets.py index b6a41587da..4809b780a9 100644 --- a/cms/djangoapps/contentstore/management/commands/cleanup_assets.py +++ b/cms/djangoapps/contentstore/management/commands/cleanup_assets.py @@ -32,8 +32,8 @@ class Command(BaseCommand): # Remove all redundant Mac OS metadata files assets_deleted = content_store.remove_redundant_content_for_courses() success = True - except Exception as err: - log.info("=" * 30 + u"> failed to cleanup") + except Exception as err: # lint-amnesty, pylint: disable=broad-except + log.info("=" * 30 + u"> failed to cleanup") # lint-amnesty, pylint: disable=logging-not-lazy log.info("Error:") log.info(err) diff --git a/cms/djangoapps/contentstore/management/commands/create_course.py b/cms/djangoapps/contentstore/management/commands/create_course.py index d48b24e858..d582de49fd 100644 --- a/cms/djangoapps/contentstore/management/commands/create_course.py +++ b/cms/djangoapps/contentstore/management/commands/create_course.py @@ -5,7 +5,7 @@ Django management command to create a course in a specific modulestore from datetime import datetime, timedelta -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, CommandError from six import text_type @@ -53,7 +53,7 @@ class Command(BaseCommand): try: user_object = user_from_str(user) except User.DoesNotExist: - raise CommandError(u"No user {user} found.".format(user=user)) + raise CommandError(u"No user {user} found.".format(user=user)) # lint-amnesty, pylint: disable=raise-missing-from return user_object def handle(self, *args, **options): diff --git a/cms/djangoapps/contentstore/management/commands/delete_course.py b/cms/djangoapps/contentstore/management/commands/delete_course.py index fe8553b679..21b63c8ae9 100644 --- a/cms/djangoapps/contentstore/management/commands/delete_course.py +++ b/cms/djangoapps/contentstore/management/commands/delete_course.py @@ -68,7 +68,7 @@ class Command(BaseCommand): course_key = text_type(options['course_key']) course_key = CourseKey.from_string(course_key) except InvalidKeyError: - raise CommandError(u'Invalid course_key: {}'.format(options['course_key'])) + raise CommandError(u'Invalid course_key: {}'.format(options['course_key'])) # lint-amnesty, pylint: disable=raise-missing-from if not modulestore().get_course(course_key): raise CommandError(u'Course not found: {}'.format(options['course_key'])) @@ -81,6 +81,6 @@ class Command(BaseCommand): if options['remove_assets']: contentstore().delete_all_course_assets(course_key) - print(u'Deleted assets for course'.format(course_key)) + print(u'Deleted assets for course'.format(course_key)) # lint-amnesty, pylint: disable=too-many-format-args print(u'Deleted course {}'.format(course_key)) diff --git a/cms/djangoapps/contentstore/management/commands/delete_orphans.py b/cms/djangoapps/contentstore/management/commands/delete_orphans.py index d52f44a6c8..61550fa22b 100644 --- a/cms/djangoapps/contentstore/management/commands/delete_orphans.py +++ b/cms/djangoapps/contentstore/management/commands/delete_orphans.py @@ -25,7 +25,7 @@ class Command(BaseCommand): try: course_key = CourseKey.from_string(options['course_id']) except InvalidKeyError: - raise CommandError("Invalid course key.") + raise CommandError("Invalid course key.") # lint-amnesty, pylint: disable=raise-missing-from if options['commit']: print('Deleting orphans from the course:') diff --git a/cms/djangoapps/contentstore/management/commands/edit_course_tabs.py b/cms/djangoapps/contentstore/management/commands/edit_course_tabs.py index f4c6ed6c9b..32a817308a 100644 --- a/cms/djangoapps/contentstore/management/commands/edit_course_tabs.py +++ b/cms/djangoapps/contentstore/management/commands/edit_course_tabs.py @@ -1,3 +1,4 @@ +# lint-amnesty, pylint: disable=missing-module-docstring ### ### Script for editing the course's tabs ### @@ -37,7 +38,7 @@ def print_course(course): # {u'type': u'progress', u'name': u'Progress'}] -class Command(BaseCommand): +class Command(BaseCommand): # lint-amnesty, pylint: disable=missing-class-docstring help = """See and edit a course's tabs list. Only supports insertion and deletion. Move and rename etc. can be done with a delete followed by an insert. The tabs are numbered starting with 1. @@ -97,4 +98,4 @@ command again, adding --insert or --delete to edit the list. tabs.primitive_insert(course, num - 1, tab_type, name) # -1 as above except ValueError as e: # Cute: translate to CommandError so the CLI error prints nicely. - raise CommandError(e) + raise CommandError(e) # lint-amnesty, pylint: disable=raise-missing-from diff --git a/cms/djangoapps/contentstore/management/commands/export.py b/cms/djangoapps/contentstore/management/commands/export.py index 99fab8105f..43b22305d7 100644 --- a/cms/djangoapps/contentstore/management/commands/export.py +++ b/cms/djangoapps/contentstore/management/commands/export.py @@ -32,7 +32,7 @@ class Command(BaseCommand): try: course_key = CourseKey.from_string(options['course_id']) except InvalidKeyError: - raise CommandError(u"Invalid course_key: '%s'." % options['course_id']) + raise CommandError(u"Invalid course_key: '%s'." % options['course_id']) # lint-amnesty, pylint: disable=raise-missing-from if not modulestore().get_course(course_key): raise CommandError(u"Course with %s key not found." % options['course_id']) diff --git a/cms/djangoapps/contentstore/management/commands/export_content_library.py b/cms/djangoapps/contentstore/management/commands/export_content_library.py index 8a9e6b82cb..810821dae1 100644 --- a/cms/djangoapps/contentstore/management/commands/export_content_library.py +++ b/cms/djangoapps/contentstore/management/commands/export_content_library.py @@ -34,7 +34,7 @@ class Command(BaseCommand): try: library_key = CourseKey.from_string(options['library_id']) except InvalidKeyError: - raise CommandError(u'Invalid library ID: "{0}".'.format(options['library_id'])) + raise CommandError(u'Invalid library ID: "{0}".'.format(options['library_id'])) # lint-amnesty, pylint: disable=raise-missing-from if not isinstance(library_key, LibraryLocator): raise CommandError(u'Argument "{0}" is not a library key'.format(options['library_id'])) @@ -50,7 +50,7 @@ class Command(BaseCommand): # Generate archive using the handy tasks implementation tarball = tasks.create_export_tarball(library, library_key, {}, None) except Exception as e: - raise CommandError(u'Failed to export "{0}" with "{1}"'.format(library_key, e)) + raise CommandError(u'Failed to export "{0}" with "{1}"'.format(library_key, e)) # lint-amnesty, pylint: disable=raise-missing-from else: with tarball: # Save generated archive with keyed filename diff --git a/cms/djangoapps/contentstore/management/commands/export_olx.py b/cms/djangoapps/contentstore/management/commands/export_olx.py index 456727f8e1..52e0c051bb 100644 --- a/cms/djangoapps/contentstore/management/commands/export_olx.py +++ b/cms/djangoapps/contentstore/management/commands/export_olx.py @@ -47,9 +47,9 @@ class Command(BaseCommand): try: course_key = CourseKey.from_string(course_id) except InvalidKeyError: - raise CommandError("Unparsable course_id") + raise CommandError("Unparsable course_id") # lint-amnesty, pylint: disable=raise-missing-from except IndexError: - raise CommandError("Insufficient arguments") + raise CommandError("Insufficient arguments") # lint-amnesty, pylint: disable=raise-missing-from filename = options['output'] pipe_results = False diff --git a/cms/djangoapps/contentstore/management/commands/force_publish.py b/cms/djangoapps/contentstore/management/commands/force_publish.py index 88931cdf98..75d841a6f0 100644 --- a/cms/djangoapps/contentstore/management/commands/force_publish.py +++ b/cms/djangoapps/contentstore/management/commands/force_publish.py @@ -36,7 +36,7 @@ class Command(BaseCommand): try: course_key = CourseKey.from_string(options['course_key']) except InvalidKeyError: - raise CommandError("Invalid course key.") + raise CommandError("Invalid course key.") # lint-amnesty, pylint: disable=raise-missing-from if not modulestore().get_course(course_key): raise CommandError("Course not found.") diff --git a/cms/djangoapps/contentstore/management/commands/generate_courses.py b/cms/djangoapps/contentstore/management/commands/generate_courses.py index 6f9e56c748..4cab7fdc39 100644 --- a/cms/djangoapps/contentstore/management/commands/generate_courses.py +++ b/cms/djangoapps/contentstore/management/commands/generate_courses.py @@ -6,7 +6,7 @@ Django management command to generate a test course from a course config json import json 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, CommandError from six import text_type @@ -34,9 +34,9 @@ class Command(BaseCommand): try: courses = json.loads(options["courses_json"])["courses"] except ValueError: - raise CommandError("Invalid JSON object") + raise CommandError("Invalid JSON object") # lint-amnesty, pylint: disable=raise-missing-from except KeyError: - raise CommandError("JSON object is missing courses list") + raise CommandError("JSON object is missing courses list") # lint-amnesty, pylint: disable=raise-missing-from for course_settings in courses: # Validate course @@ -52,7 +52,7 @@ class Command(BaseCommand): try: user = user_from_str(user_email) except User.DoesNotExist: - logger.warning(user_email + " user does not exist") + logger.warning(user_email + " user does not exist") # lint-amnesty, pylint: disable=logging-not-lazy logger.warning("Can't create course, proceeding to next course") continue fields = self._process_course_fields(course_settings["fields"]) @@ -102,7 +102,7 @@ class Command(BaseCommand): if field not in all_fields: # field does not exist as a CourseField del fields[field] - logger.info(field + "is not a valid CourseField") + logger.info(field + "is not a valid CourseField") # lint-amnesty, pylint: disable=logging-not-lazy elif fields[field] is None: # field is unset del fields[field] @@ -113,7 +113,7 @@ class Command(BaseCommand): fields[field] = Date().from_json(date_json) logger.info(field + " has been set to " + date_json) except Exception: # pylint: disable=broad-except - logger.info("The date string could not be parsed for " + field) + logger.info("The date string could not be parsed for " + field) # lint-amnesty, pylint: disable=logging-not-lazy del fields[field] elif field in course_tab_list_fields: # Generate CourseTabList object from the json value @@ -122,15 +122,15 @@ class Command(BaseCommand): fields[field] = CourseTabList().from_json(course_tab_list_json) logger.info(field + " has been set to " + course_tab_list_json) except Exception: # pylint: disable=broad-except - logger.info("The course tab list string could not be parsed for " + field) + logger.info("The course tab list string could not be parsed for " + field) # lint-amnesty, pylint: disable=logging-not-lazy del fields[field] else: # CourseField is valid and has been set - logger.info(field + " has been set to " + str(fields[field])) + logger.info(field + " has been set to " + str(fields[field])) # lint-amnesty, pylint: disable=logging-not-lazy for field in all_fields: if field not in fields: - logger.info(field + " has not been set") + logger.info(field + " has not been set") # lint-amnesty, pylint: disable=logging-not-lazy return fields def _course_is_valid(self, course): @@ -147,7 +147,7 @@ class Command(BaseCommand): ] for setting in required_course_settings: if setting not in course: - logger.warning("Course json is missing " + setting) + logger.warning("Course json is missing " + setting) # lint-amnesty, pylint: disable=logging-not-lazy is_valid = False # Check fields settings @@ -157,7 +157,7 @@ class Command(BaseCommand): if "fields" in course: for setting in required_field_settings: if setting not in course["fields"]: - logger.warning("Fields json is missing " + setting) + logger.warning("Fields json is missing " + setting) # lint-amnesty, pylint: disable=logging-not-lazy is_valid = False return is_valid diff --git a/cms/djangoapps/contentstore/management/commands/git_export.py b/cms/djangoapps/contentstore/management/commands/git_export.py index 6eaf3fb8f1..1edb40a107 100644 --- a/cms/djangoapps/contentstore/management/commands/git_export.py +++ b/cms/djangoapps/contentstore/management/commands/git_export.py @@ -51,7 +51,7 @@ class Command(BaseCommand): try: course_key = CourseKey.from_string(options['course_loc']) except InvalidKeyError: - raise CommandError(text_type(git_export_utils.GitExportError.BAD_COURSE)) + raise CommandError(text_type(git_export_utils.GitExportError.BAD_COURSE)) # lint-amnesty, pylint: disable=raise-missing-from try: git_export_utils.export_to_git( @@ -61,4 +61,4 @@ class Command(BaseCommand): options.get('rdir', None) ) except git_export_utils.GitExportError as ex: - raise CommandError(text_type(ex)) + raise CommandError(text_type(ex)) # lint-amnesty, pylint: disable=raise-missing-from diff --git a/cms/djangoapps/contentstore/management/commands/import_content_library.py b/cms/djangoapps/contentstore/management/commands/import_content_library.py index 6b22340916..8892d26f25 100644 --- a/cms/djangoapps/contentstore/management/commands/import_content_library.py +++ b/cms/djangoapps/contentstore/management/commands/import_content_library.py @@ -8,7 +8,7 @@ import os import tarfile 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 SuspiciousOperation from django.core.management.base import BaseCommand, CommandError from lxml import etree @@ -52,7 +52,7 @@ class Command(BaseCommand): try: safetar_extractall(tar_file, course_dir.encode('utf-8')) except SuspiciousOperation as exc: - raise CommandError(u'\n=== Course import {0}: Unsafe tar file - {1}\n'.format(archive_path, exc.args[0])) + raise CommandError(u'\n=== Course import {0}: Unsafe tar file - {1}\n'.format(archive_path, exc.args[0])) # lint-amnesty, pylint: disable=raise-missing-from finally: tar_file.close() diff --git a/cms/djangoapps/contentstore/management/commands/migrate_to_split.py b/cms/djangoapps/contentstore/management/commands/migrate_to_split.py index 955819f3cd..2e3abf97cd 100644 --- a/cms/djangoapps/contentstore/management/commands/migrate_to_split.py +++ b/cms/djangoapps/contentstore/management/commands/migrate_to_split.py @@ -4,7 +4,7 @@ to the new split-Mongo modulestore. """ -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, CommandError from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey @@ -37,12 +37,12 @@ class Command(BaseCommand): try: course_key = CourseKey.from_string(options['course_key']) except InvalidKeyError: - raise CommandError("Invalid location string") + raise CommandError("Invalid location string") # lint-amnesty, pylint: disable=raise-missing-from try: user = user_from_str(options['email']) except User.DoesNotExist: - raise CommandError(u"No user found identified by {}".format(options['email'])) + raise CommandError(u"No user found identified by {}".format(options['email'])) # lint-amnesty, pylint: disable=raise-missing-from return course_key, user.id, options['org'], options['course'], options['run'] @@ -51,7 +51,7 @@ class Command(BaseCommand): migrator = SplitMigrator( source_modulestore=modulestore(), - split_modulestore=modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split), + split_modulestore=modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split), # lint-amnesty, pylint: disable=protected-access ) migrator.migrate_mongo_course(course_key, user, org, course, run) diff --git a/cms/djangoapps/contentstore/management/commands/reindex_course.py b/cms/djangoapps/contentstore/management/commands/reindex_course.py index c84af51ade..aa9bd8bfd2 100644 --- a/cms/djangoapps/contentstore/management/commands/reindex_course.py +++ b/cms/djangoapps/contentstore/management/commands/reindex_course.py @@ -47,7 +47,7 @@ class Command(BaseCommand): try: result = CourseKey.from_string(raw_value) except InvalidKeyError: - raise CommandError(u"Invalid course_key: '%s'." % raw_value) + raise CommandError(u"Invalid course_key: '%s'." % raw_value) # lint-amnesty, pylint: disable=raise-missing-from if not isinstance(result, CourseLocator): raise CommandError(u"Argument {0} is not a course key".format(raw_value)) @@ -64,8 +64,7 @@ class Command(BaseCommand): setup_option = options['setup'] index_all_courses_option = all_option or setup_option - if (not len(course_ids) and not index_all_courses_option) or \ - (len(course_ids) and index_all_courses_option): + if (not len(course_ids) and not index_all_courses_option) or (len(course_ids) and index_all_courses_option): # lint-amnesty, pylint: disable=len-as-condition raise CommandError("reindex_course requires one or more s OR the --all or --setup flags.") store = modulestore() @@ -103,5 +102,5 @@ class Command(BaseCommand): for course_key in course_keys: try: CoursewareSearchIndexer.do_course_reindex(store, course_key) - except Exception as exc: + except Exception as exc: # lint-amnesty, pylint: disable=broad-except logging.exception('Error indexing course %s due to the error: %s', course_key, exc) diff --git a/cms/djangoapps/contentstore/management/commands/sync_courses.py b/cms/djangoapps/contentstore/management/commands/sync_courses.py index ea48234264..68fa50010b 100644 --- a/cms/djangoapps/contentstore/management/commands/sync_courses.py +++ b/cms/djangoapps/contentstore/management/commands/sync_courses.py @@ -5,7 +5,7 @@ integration environment. import logging from textwrap import dedent -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, CommandError from opaque_keys.edx.keys import CourseKey from six import text_type @@ -37,7 +37,7 @@ class Command(BaseCommand): try: user_object = user_from_str(user) except User.DoesNotExist: - raise CommandError(u"No user {user} found.".format(user=user)) + raise CommandError(u"No user {user} found.".format(user=user)) # lint-amnesty, pylint: disable=raise-missing-from return user_object def handle(self, *args, **options): diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_cleanup_assets.py b/cms/djangoapps/contentstore/management/commands/tests/test_cleanup_assets.py index 0f4441fbcb..3086fa68fd 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_cleanup_assets.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_cleanup_assets.py @@ -28,7 +28,7 @@ class ExportAllCourses(ModuleStoreTestCase): def setUp(self): """ Common setup. """ - super(ExportAllCourses, self).setUp() + super(ExportAllCourses, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.content_store = contentstore() # pylint: disable=protected-access self.module_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo) @@ -56,7 +56,7 @@ class ExportAllCourses(ModuleStoreTestCase): # check that there are two assets ['example.txt', '.example.txt'] in contentstore for imported course all_assets, count = self.content_store.get_all_content_for_course(course.id) self.assertEqual(count, 2) - self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt'])) + self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt'])) # lint-amnesty, pylint: disable=consider-using-set-comprehension # manually add redundant assets (file ".DS_Store" and filename starts with "._") course_filter = course.id.make_asset_key("asset", None) @@ -72,11 +72,11 @@ class ExportAllCourses(ModuleStoreTestCase): all_assets, count = self.content_store.get_all_content_for_course(course.id) self.assertEqual(count, 4) self.assertEqual( - set([asset['_id']['name'] for asset in all_assets]), + set([asset['_id']['name'] for asset in all_assets]), # lint-amnesty, pylint: disable=consider-using-set-comprehension set([u'.example.txt', u'example.txt', u'._example_test.txt', u'.DS_Store']) ) # now call asset_cleanup command and check that there is only two proper assets in contentstore for the course call_command('cleanup_assets') all_assets, count = self.content_store.get_all_content_for_course(course.id) self.assertEqual(count, 2) - self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt'])) + self.assertEqual(set([asset['_id']['name'] for asset in all_assets]), set([u'.example.txt', u'example.txt'])) # lint-amnesty, pylint: disable=consider-using-set-comprehension diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py b/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py index b0a6407575..7f57119a43 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py @@ -18,8 +18,8 @@ class TestArgParsing(TestCase): """ Tests for parsing arguments for the `create_course` management command """ - def setUp(self): - super(TestArgParsing, self).setUp() + def setUp(self): # lint-amnesty, pylint: disable=useless-super-delegation + super(TestArgParsing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments def test_no_args(self): if six.PY2: diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_export.py b/cms/djangoapps/contentstore/management/commands/tests/test_export.py index e5127f34e4..0967c71f8f 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_export.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_export.py @@ -39,7 +39,7 @@ class TestCourseExport(ModuleStoreTestCase): Test exporting a course """ def setUp(self): - super(TestCourseExport, self).setUp() + super(TestCourseExport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Temp directories (temp_dir_1: relative path, temp_dir_2: absolute path) self.temp_dir_1 = mkdtemp() diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_export_all_courses.py b/cms/djangoapps/contentstore/management/commands/tests/test_export_all_courses.py index 60ec6f9b0d..29655df100 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_export_all_courses.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_export_all_courses.py @@ -21,8 +21,8 @@ class ExportAllCourses(ModuleStoreTestCase): """ def setUp(self): """ Common setup. """ - super(ExportAllCourses, self).setUp() - self.store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo) + super(ExportAllCourses, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments + self.store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo) # lint-amnesty, pylint: disable=protected-access self.temp_dir = mkdtemp() self.addCleanup(shutil.rmtree, self.temp_dir) self.first_course = CourseFactory.create( diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_force_publish.py b/cms/djangoapps/contentstore/management/commands/tests/test_force_publish.py index 8401d8bdca..423be9d53e 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_force_publish.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_force_publish.py @@ -78,7 +78,7 @@ class TestForcePublishModifications(ModuleStoreTestCase): """ def setUp(self): - super(TestForcePublishModifications, self).setUp() + super(TestForcePublishModifications, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split) self.test_user_id = ModuleStoreEnum.UserID.test self.command = Command() diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py b/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py index 79c74d3ee6..01564d5042 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py @@ -39,7 +39,7 @@ class TestGitExport(CourseTestCase): """ Create/reinitialize bare repo and folders needed """ - super(TestGitExport, self).setUp() + super(TestGitExport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments if not os.path.isdir(git_export_utils.GIT_REPO_EXPORT_DIR): os.mkdir(git_export_utils.GIT_REPO_EXPORT_DIR) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_import.py b/cms/djangoapps/contentstore/management/commands/tests/test_import.py index 1d2263c3f4..65e73d537c 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_import.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_import.py @@ -22,7 +22,7 @@ class TestImport(ModuleStoreTestCase): Unit tests for importing a course from command line """ - def create_course_xml(self, content_dir, course_id): + def create_course_xml(self, content_dir, course_id): # lint-amnesty, pylint: disable=missing-function-docstring directory = tempfile.mkdtemp(dir=content_dir) os.makedirs(os.path.join(directory, "course")) with open(os.path.join(directory, "course.xml"), "w+") as f: @@ -37,7 +37,7 @@ class TestImport(ModuleStoreTestCase): """ Build course XML for importing """ - super(TestImport, self).setUp() + super(TestImport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.content_dir = path(tempfile.mkdtemp()) self.addCleanup(shutil.rmtree, self.content_dir) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py index 85bdc670f5..63f2b54cb6 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py @@ -18,8 +18,8 @@ class TestArgParsing(TestCase): """ Tests for parsing arguments for the `migrate_to_split` management command """ - def setUp(self): - super(TestArgParsing, self).setUp() + def setUp(self): # lint-amnesty, pylint: disable=useless-super-delegation + super(TestArgParsing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments def test_no_args(self): """ @@ -64,7 +64,7 @@ class TestMigrateToSplit(ModuleStoreTestCase): """ def setUp(self): - super(TestMigrateToSplit, self).setUp() + super(TestMigrateToSplit, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory(default_store=ModuleStoreEnum.Type.mongo) def test_user_email(self): @@ -73,11 +73,11 @@ class TestMigrateToSplit(ModuleStoreTestCase): """ call_command( "migrate_to_split", - str(self.course.id), + str(self.course.id), # lint-amnesty, pylint: disable=no-member str(self.user.email), ) split_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split) - new_key = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) + new_key = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) # lint-amnesty, pylint: disable=no-member self.assertTrue( split_store.has_course(new_key), "Could not find course" @@ -90,7 +90,7 @@ class TestMigrateToSplit(ModuleStoreTestCase): # lack of error implies success call_command( "migrate_to_split", - str(self.course.id), + str(self.course.id), # lint-amnesty, pylint: disable=no-member str(self.user.id), ) @@ -100,7 +100,7 @@ class TestMigrateToSplit(ModuleStoreTestCase): """ call_command( "migrate_to_split", - str(self.course.id), + str(self.course.id), # lint-amnesty, pylint: disable=no-member str(self.user.id), org="org.dept", course="name", @@ -113,11 +113,11 @@ class TestMigrateToSplit(ModuleStoreTestCase): # Getting the original course with mongo course_id mongo_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo) - mongo_locator = mongo_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) + mongo_locator = mongo_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) # lint-amnesty, pylint: disable=no-member course_from_mongo = mongo_store.get_course(mongo_locator) self.assertIsNotNone(course_from_mongo) # Throws ItemNotFoundError when try to access original course with split course_id - split_locator = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) + split_locator = split_store.make_course_key(self.course.id.org, self.course.id.course, self.course.id.run) # lint-amnesty, pylint: disable=no-member with self.assertRaises(ItemNotFoundError): mongo_store.get_course(split_locator) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py index 7f8a7a860d..539b676960 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py @@ -7,7 +7,7 @@ import six from django.core.management import CommandError, call_command from six import text_type -from cms.djangoapps.contentstore.courseware_index import SearchIndexingError +from cms.djangoapps.contentstore.courseware_index import SearchIndexingError # lint-amnesty, pylint: disable=unused-import from cms.djangoapps.contentstore.management.commands.reindex_course import Command as ReindexCommand from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore @@ -20,7 +20,7 @@ class TestReindexCourse(ModuleStoreTestCase): """ Tests for course reindex command """ def setUp(self): """ Setup method - create courses """ - super(TestReindexCourse, self).setUp() + super(TestReindexCourse, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.store = modulestore() self.first_lib = LibraryFactory.create( org="test", library="lib1", display_name="run1", default_store=ModuleStoreEnum.Type.split diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py index 7397872ac5..3e540c8501 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py @@ -20,7 +20,7 @@ class TestReindexLibrary(ModuleStoreTestCase): """ Tests for library reindex command """ def setUp(self): """ Setup method - create libraries and courses """ - super(TestReindexLibrary, self).setUp() + super(TestReindexLibrary, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.store = modulestore() self.first_lib = LibraryFactory.create( org="test", library="lib1", display_name="run1", default_store=ModuleStoreEnum.Type.split diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_sync_courses.py b/cms/djangoapps/contentstore/management/commands/tests/test_sync_courses.py index 276f858a53..e181fc17e2 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_sync_courses.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_sync_courses.py @@ -22,7 +22,7 @@ class TestSyncCoursesCommand(ModuleStoreTestCase): """ Test sync_courses command """ def setUp(self): - super(TestSyncCoursesCommand, self).setUp() + super(TestSyncCoursesCommand, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory(username='test', email='test@example.com') self.catalog_course_runs = [ @@ -32,9 +32,9 @@ class TestSyncCoursesCommand(ModuleStoreTestCase): def _validate_courses(self): for run in self.catalog_course_runs: - course_key = CourseKey.from_string(run.get('key')) + course_key = CourseKey.from_string(run.get('key')) # lint-amnesty, pylint: disable=no-member self.assertTrue(modulestore().has_course(course_key)) - CourseOverview.objects.get(id=run.get('key')) + CourseOverview.objects.get(id=run.get('key')) # lint-amnesty, pylint: disable=no-member def test_courses_sync(self, mock_catalog_course_runs): mock_catalog_course_runs.return_value = self.catalog_course_runs diff --git a/cms/djangoapps/contentstore/management/commands/utils.py b/cms/djangoapps/contentstore/management/commands/utils.py index d970d23e6d..be697e0306 100644 --- a/cms/djangoapps/contentstore/management/commands/utils.py +++ b/cms/djangoapps/contentstore/management/commands/utils.py @@ -3,7 +3,7 @@ Common methods for cms commands to use """ -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 xmodule.modulestore.django import modulestore diff --git a/cms/djangoapps/contentstore/proctoring.py b/cms/djangoapps/contentstore/proctoring.py index 42e8250956..fc9ea55c97 100644 --- a/cms/djangoapps/contentstore/proctoring.py +++ b/cms/djangoapps/contentstore/proctoring.py @@ -39,7 +39,7 @@ def register_special_exams(course_key): course = modulestore().get_course(course_key) if course is None: - raise ItemNotFoundError(u"Course {} does not exist", six.text_type(course_key)) + raise ItemNotFoundError(u"Course {} does not exist", six.text_type(course_key)) # lint-amnesty, pylint: disable=raising-format-tuple if not course.enable_proctored_exams and not course.enable_timed_exams: # likewise if course does not have these features turned on diff --git a/cms/djangoapps/contentstore/signals/handlers.py b/cms/djangoapps/contentstore/signals/handlers.py index baadf49a02..69c1421df3 100644 --- a/cms/djangoapps/contentstore/signals/handlers.py +++ b/cms/djangoapps/contentstore/signals/handlers.py @@ -30,7 +30,7 @@ log = logging.getLogger(__name__) GRADING_POLICY_COUNTDOWN_SECONDS = 3600 -def locked(expiry_seconds, key): +def locked(expiry_seconds, key): # lint-amnesty, pylint: disable=missing-function-docstring def task_decorator(func): @wraps(func) def wrapper(*args, **kwargs): diff --git a/cms/djangoapps/contentstore/storage.py b/cms/djangoapps/contentstore/storage.py index e8aed444e1..0757676676 100644 --- a/cms/djangoapps/contentstore/storage.py +++ b/cms/djangoapps/contentstore/storage.py @@ -16,7 +16,7 @@ class ImportExportS3Storage(S3BotoStorage): # pylint: disable=abstract-method def __init__(self): bucket = setting('COURSE_IMPORT_EXPORT_BUCKET', settings.AWS_STORAGE_BUCKET_NAME) - super(ImportExportS3Storage, self).__init__(bucket=bucket, custom_domain=None, querystring_auth=True) + super(ImportExportS3Storage, self).__init__(bucket=bucket, custom_domain=None, querystring_auth=True) # lint-amnesty, pylint: disable=super-with-arguments # pylint: disable=invalid-name course_import_export_storage = get_storage_class(settings.COURSE_IMPORT_EXPORT_STORAGE)() diff --git a/cms/djangoapps/contentstore/tasks.py b/cms/djangoapps/contentstore/tasks.py index 90935463a5..2768a80525 100644 --- a/cms/djangoapps/contentstore/tasks.py +++ b/cms/djangoapps/contentstore/tasks.py @@ -16,7 +16,7 @@ from celery import shared_task from celery.utils.log import get_task_logger from django.conf import settings from django.contrib.auth import get_user_model -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 SuspiciousOperation from django.core.files import File from django.test import RequestFactory @@ -384,7 +384,7 @@ class CourseImportTask(UserTask): # pylint: disable=abstract-method @shared_task(base=CourseImportTask, bind=True) -# Note: The decorator @set_code_owner_attribute could not be used because +# Note: The decorator @set_code_owner_attribute could not be used because # lint-amnesty, pylint: disable=too-many-statements # the implementation of this task breaks with any additional decorators. def import_olx(self, user_id, course_key_string, archive_path, archive_name, language): """ diff --git a/cms/djangoapps/contentstore/tests/test_clone_course.py b/cms/djangoapps/contentstore/tests/test_clone_course.py index d37ddb6823..120944d63a 100644 --- a/cms/djangoapps/contentstore/tests/test_clone_course.py +++ b/cms/djangoapps/contentstore/tests/test_clone_course.py @@ -79,7 +79,7 @@ class CloneCourseTest(CourseTestCase): # Get & verify all assets of the course assets, count = contentstore().get_all_content_for_course(course.id) self.assertEqual(count, 1) - self.assertEqual(set([asset['asset_key'].block_id for asset in assets]), course_assets) + self.assertEqual(set([asset['asset_key'].block_id for asset in assets]), course_assets) # lint-amnesty, pylint: disable=consider-using-set-comprehension # rerun from split into split split_rerun_id = CourseLocator(org=org, course=course_number, run="2012_Q2") @@ -126,7 +126,7 @@ class CloneCourseTest(CourseTestCase): ) # try to hit the generic exception catch - with patch('xmodule.modulestore.split_mongo.mongo_connection.MongoConnection.insert_course_index', Mock(side_effect=Exception)): + with patch('xmodule.modulestore.split_mongo.mongo_connection.MongoConnection.insert_course_index', Mock(side_effect=Exception)): # lint-amnesty, pylint: disable=line-too-long split_course4_id = CourseLocator(org="edx3", course="split3", run="rerun_fail") fields = {'display_name': 'total failure'} CourseRerunState.objects.initiated(split_course3_id, split_course4_id, self.user, fields['display_name']) diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index f8fadc33c5..33aee44986 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# lint-amnesty, pylint: disable=missing-module-docstring import copy @@ -15,8 +15,8 @@ import lxml.html import mock import six from django.conf import settings -from django.contrib.auth.models import User -from django.middleware.csrf import _compare_salted_tokens +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user +from django.middleware.csrf import _compare_salted_tokens # lint-amnesty, pylint: disable=unused-import from django.test import TestCase from django.test.utils import override_settings from edxval.api import create_video, get_videos_for_course @@ -76,7 +76,7 @@ def requires_pillow_jpeg(func): try: from PIL import Image except ImportError: - raise SkipTest("Pillow is not installed (or not found)") + raise SkipTest("Pillow is not installed (or not found)") # lint-amnesty, pylint: disable=raise-missing-from if not getattr(Image.core, "jpeg_decoder", False): raise SkipTest("Pillow cannot open JPEG files") return func(*args, **kwargs) @@ -297,7 +297,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): html_module = self.store.get_item(html_module_location) self.assertIn('/jump_to_id/nonportable_link', html_module.data) - def verify_content_existence(self, store, root_dir, course_id, dirname, category_name, filename_suffix=''): + def verify_content_existence(self, store, root_dir, course_id, dirname, category_name, filename_suffix=''): # lint-amnesty, pylint: disable=missing-function-docstring filesystem = OSFS(root_dir / 'test_export') self.assertTrue(filesystem.exists(dirname)) @@ -614,7 +614,7 @@ class MiscCourseTests(ContentStoreTestCase): """ def setUp(self): - super(MiscCourseTests, self).setUp() + super(MiscCourseTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # save locs not items b/c the items won't have the subsequently created children in them until refetched self.chapter_loc = self.store.create_child( self.user.id, self.course.location, 'chapter', 'test_chapter' @@ -802,7 +802,7 @@ class MiscCourseTests(ContentStoreTestCase): """Verifies rendering the editor in all the verticals in the given test course""" self._check_verticals([self.vert_loc]) - def _get_draft_counts(self, item): + def _get_draft_counts(self, item): # lint-amnesty, pylint: disable=missing-function-docstring cnt = 1 if getattr(item, 'is_draft', False) else 0 for child in item.get_children(): cnt = cnt + self._get_draft_counts(child) @@ -1161,7 +1161,7 @@ class ContentStoreTest(ContentStoreTestCase): "Please change either organization or course number to be unique.") def setUp(self): - super(ContentStoreTest, self).setUp() + super(ContentStoreTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_data = { 'org': 'MITx', @@ -1494,7 +1494,7 @@ class ContentStoreTest(ContentStoreTestCase): resp = self._show_course_overview(course.id) self.assertContains( resp, - '
'.format( + '
'.format( # lint-amnesty, pylint: disable=line-too-long locator=text_type(course.location), course_key=text_type(course.id), ), @@ -1536,7 +1536,7 @@ class ContentStoreTest(ContentStoreTestCase): self.assertIsInstance(problem, ProblemBlock, "New problem is not a ProblemBlock") context = problem.get_context() self.assertIn('markdown', context, "markdown is missing from context") - self.assertNotIn('markdown', problem.editable_metadata_fields, "Markdown slipped into the editable metadata fields") + self.assertNotIn('markdown', problem.editable_metadata_fields, "Markdown slipped into the editable metadata fields") # lint-amnesty, pylint: disable=line-too-long def test_cms_imported_course_walkthrough(self): """ @@ -1806,7 +1806,7 @@ class MetadataSaveTestCase(ContentStoreTestCase): """Test that metadata is correctly cached and decached.""" def setUp(self): - super(MetadataSaveTestCase, self).setUp() + super(MetadataSaveTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments course = CourseFactory.create() @@ -1866,7 +1866,7 @@ class RerunCourseTest(ContentStoreTestCase): """ def setUp(self): - super(RerunCourseTest, self).setUp() + super(RerunCourseTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.destination_course_data = { 'org': 'MITx', 'number': '111', @@ -2174,7 +2174,7 @@ class EntryPageTestCase(TestCase): """ def setUp(self): - super(EntryPageTestCase, self).setUp() + super(EntryPageTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.client = AjaxEnabledTestClient() def _test_page(self, page, status_code=200): diff --git a/cms/djangoapps/contentstore/tests/test_course_create_rerun.py b/cms/djangoapps/contentstore/tests/test_course_create_rerun.py index 391815f278..4961e010ce 100644 --- a/cms/djangoapps/contentstore/tests/test_course_create_rerun.py +++ b/cms/djangoapps/contentstore/tests/test_course_create_rerun.py @@ -37,7 +37,7 @@ class TestCourseListing(ModuleStoreTestCase): """ Add a user and a course """ - super(TestCourseListing, self).setUp() + super(TestCourseListing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # create and log in a staff user. # create and log in a non-staff user self.user = UserFactory() diff --git a/cms/djangoapps/contentstore/tests/test_course_listing.py b/cms/djangoapps/contentstore/tests/test_course_listing.py index e80e506404..0502bf9201 100644 --- a/cms/djangoapps/contentstore/tests/test_course_listing.py +++ b/cms/djangoapps/contentstore/tests/test_course_listing.py @@ -51,7 +51,7 @@ class TestCourseListing(ModuleStoreTestCase): """ Add a user and a course """ - super(TestCourseListing, self).setUp() + super(TestCourseListing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # create and log in a staff user. # create and log in a non-staff user self.user = UserFactory() diff --git a/cms/djangoapps/contentstore/tests/test_course_settings.py b/cms/djangoapps/contentstore/tests/test_course_settings.py index deaab43e11..0d52d95d1a 100644 --- a/cms/djangoapps/contentstore/tests/test_course_settings.py +++ b/cms/djangoapps/contentstore/tests/test_course_settings.py @@ -100,7 +100,7 @@ class CourseAdvanceSettingViewTest(CourseTestCase, MilestonesTestCaseMixin): """ def setUp(self): - super(CourseAdvanceSettingViewTest, self).setUp() + super(CourseAdvanceSettingViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.fullcourse = CourseFactory.create() self.course_setting_url = get_url(self.course.id, 'advanced_settings_handler') @@ -916,7 +916,7 @@ class CourseMetadataEditingTest(CourseTestCase): """ def setUp(self): - super(CourseMetadataEditingTest, self).setUp() + super(CourseMetadataEditingTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.fullcourse = CourseFactory.create() self.course_setting_url = get_url(self.course.id, 'advanced_settings_handler') self.fullcourse_setting_url = get_url(self.fullcourse.id, 'advanced_settings_handler') @@ -1175,7 +1175,7 @@ class CourseMetadataEditingTest(CourseTestCase): self.assertEqual(len(errors), 3) self.assertFalse(test_model) - error_keys = set([error_obj['model']['display_name'] for error_obj in errors]) + error_keys = set([error_obj['model']['display_name'] for error_obj in errors]) # lint-amnesty, pylint: disable=consider-using-set-comprehension test_keys = set(['Advanced Module List', 'Course Advertised Start Date', 'Days Early for Beta Users']) self.assertEqual(error_keys, test_keys) @@ -1527,7 +1527,7 @@ class CourseGraderUpdatesTest(CourseTestCase): def setUp(self): """Compute the url to use in tests""" - super(CourseGraderUpdatesTest, self).setUp() + super(CourseGraderUpdatesTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = get_url(self.course.id, 'grading_handler') self.starting_graders = CourseGradingModel(self.course).graders @@ -1625,7 +1625,7 @@ id=\"course-enrollment-end-time\" value=\"\" placeholder=\"HH:MM\" autocomplete= """ Initialize course used to test enrollment fields. """ - super(CourseEnrollmentEndFieldTest, self).setUp() + super(CourseEnrollmentEndFieldTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create(org='edX', number='dummy', display_name='Marketing Site Course') self.course_details_url = reverse_course_url('settings_handler', six.text_type(self.course.id)) diff --git a/cms/djangoapps/contentstore/tests/test_courseware_index.py b/cms/djangoapps/contentstore/tests/test_courseware_index.py index 5c54f70952..5c175d1ab8 100644 --- a/cms/djangoapps/contentstore/tests/test_courseware_index.py +++ b/cms/djangoapps/contentstore/tests/test_courseware_index.py @@ -18,7 +18,7 @@ from mock import patch from pytz import UTC from search.search_engine_base import SearchEngine from six.moves import range -from xblock.core import XBlock +from xblock.core import XBlock # lint-amnesty, pylint: disable=unused-import from cms.djangoapps.contentstore.courseware_index import ( CourseAboutSearchIndexer, @@ -71,7 +71,7 @@ def create_children(store, parent, category, load_factor): child_object = ItemFactory.create( parent_location=parent.location, category=category, - display_name=u"{} {} {}".format(category, child_index, time.clock()), + display_name=u"{} {} {}".format(category, child_index, time.clock()), # lint-amnesty, pylint: disable=no-member modulestore=store, publish_item=True, start=datetime(2015, 3, 1, tzinfo=UTC), @@ -140,7 +140,7 @@ class MixedWithOptionsTestCase(MixedSplitTestCase): def setup_course_base(self, store): """ base version of setup_course_base is a no-op """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass @lazy def searcher(self): @@ -195,7 +195,7 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase): WORKS_WITH_STORES = (ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) def setUp(self): - super(TestCoursewareSearchIndexer, self).setUp() + super(TestCoursewareSearchIndexer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = None self.chapter = None @@ -605,11 +605,11 @@ class TestLargeCourseDeletions(MixedWithOptionsTestCase): self.course_id = None def setUp(self): - super(TestLargeCourseDeletions, self).setUp() + super(TestLargeCourseDeletions, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_id = None def tearDown(self): - super(TestLargeCourseDeletions, self).tearDown() + super(TestLargeCourseDeletions, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments self._clean_course_id() def assert_search_count(self, expected_count): @@ -787,7 +787,7 @@ class TestLibrarySearchIndexer(MixedWithOptionsTestCase): WORKS_WITH_STORES = (ModuleStoreEnum.Type.split, ) def setUp(self): - super(TestLibrarySearchIndexer, self).setUp() + super(TestLibrarySearchIndexer, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.library = None self.html_unit1 = None @@ -937,7 +937,7 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase): INDEX_NAME = CoursewareSearchIndexer.INDEX_NAME def setUp(self): - super(GroupConfigurationSearchMongo, self).setUp() + super(GroupConfigurationSearchMongo, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self._setup_course_with_content() self._setup_split_test_module() @@ -1427,7 +1427,7 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase): mock_index.reset_mock() -class GroupConfigurationSearchSplit(GroupConfigurationSearchMongo): +class GroupConfigurationSearchSplit(GroupConfigurationSearchMongo): # lint-amnesty, pylint: disable=test-inherits-tests """ Tests indexing of content groups on course modules using split modulestore. """ diff --git a/cms/djangoapps/contentstore/tests/test_export_git.py b/cms/djangoapps/contentstore/tests/test_export_git.py index 147ff63a25..bfbd98d3f2 100644 --- a/cms/djangoapps/contentstore/tests/test_export_git.py +++ b/cms/djangoapps/contentstore/tests/test_export_git.py @@ -32,7 +32,7 @@ class TestExportGit(CourseTestCase): """ Setup test course, user, and url. """ - super(TestExportGit, self).setUp() + super(TestExportGit, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_module = modulestore().get_course(self.course.id) self.test_url = reverse_course_url('export_git', self.course.id) diff --git a/cms/djangoapps/contentstore/tests/test_gating.py b/cms/djangoapps/contentstore/tests/test_gating.py index 70be15a98a..7ed635f732 100644 --- a/cms/djangoapps/contentstore/tests/test_gating.py +++ b/cms/djangoapps/contentstore/tests/test_gating.py @@ -22,7 +22,7 @@ class TestHandleItemDeleted(ModuleStoreTestCase, MilestonesTestCaseMixin): """ Initial data setup """ - super(TestHandleItemDeleted, self).setUp() + super(TestHandleItemDeleted, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create() self.course.enable_subsection_gating = True diff --git a/cms/djangoapps/contentstore/tests/test_i18n.py b/cms/djangoapps/contentstore/tests/test_i18n.py index 69963c5903..8d0344143f 100644 --- a/cms/djangoapps/contentstore/tests/test_i18n.py +++ b/cms/djangoapps/contentstore/tests/test_i18n.py @@ -8,7 +8,7 @@ import gettext from unittest import skip 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.utils import translation from django.utils.translation import get_language @@ -62,7 +62,7 @@ class TestModuleI18nService(ModuleStoreTestCase): def setUp(self): """ Setting up tests """ - super(TestModuleI18nService, self).setUp() + super(TestModuleI18nService, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_language = 'dummy language' self.request = mock.Mock() self.course = CourseFactory.create() @@ -187,7 +187,7 @@ class InternationalizationTest(ModuleStoreTestCase): will be cleared out before each test case execution and deleted afterwards. """ - super(InternationalizationTest, self).setUp() + super(InternationalizationTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.uname = 'testuser' self.email = 'test+courses@edx.org' @@ -211,7 +211,7 @@ class InternationalizationTest(ModuleStoreTestCase): def test_course_plain_english(self): """Test viewing the index page with no courses""" - self.client = AjaxEnabledTestClient() + self.client = AjaxEnabledTestClient() # lint-amnesty, pylint: disable=attribute-defined-outside-init self.client.login(username=self.uname, password=self.password) resp = self.client.get_html('/home/') @@ -222,7 +222,7 @@ class InternationalizationTest(ModuleStoreTestCase): def test_course_explicit_english(self): """Test viewing the index page with no courses""" - self.client = AjaxEnabledTestClient() + self.client = AjaxEnabledTestClient() # lint-amnesty, pylint: disable=attribute-defined-outside-init self.client.login(username=self.uname, password=self.password) resp = self.client.get_html( @@ -247,7 +247,7 @@ class InternationalizationTest(ModuleStoreTestCase): @skip def test_course_with_accents(self): """Test viewing the index page with no courses""" - self.client = AjaxEnabledTestClient() + self.client = AjaxEnabledTestClient() # lint-amnesty, pylint: disable=attribute-defined-outside-init self.client.login(username=self.uname, password=self.password) resp = self.client.get_html( diff --git a/cms/djangoapps/contentstore/tests/test_import.py b/cms/djangoapps/contentstore/tests/test_import.py index 2e808ccfcb..61b8854f23 100644 --- a/cms/djangoapps/contentstore/tests/test_import.py +++ b/cms/djangoapps/contentstore/tests/test_import.py @@ -37,7 +37,7 @@ class ContentStoreImportTest(ModuleStoreTestCase): NOTE: refactor using CourseFactory so they do not. """ def setUp(self): - super(ContentStoreImportTest, self).setUp() + super(ContentStoreImportTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.client = Client() self.client.login(username=self.user.username, password=self.user_password) @@ -48,7 +48,7 @@ class ContentStoreImportTest(ModuleStoreTestCase): def tearDown(self): self.task_patcher.stop() - super(ContentStoreImportTest, self).tearDown() + super(ContentStoreImportTest, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments def load_test_import_course(self, target_id=None, create_if_not_present=True, module_store=None): ''' @@ -252,7 +252,7 @@ class ContentStoreImportTest(ModuleStoreTestCase): {"0": '9f0941d021414798836ef140fb5f6841', "1": '0faf29473cf1497baa33fcc828b179cd'}, ) - def _verify_split_test_import(self, target_course_name, source_course_name, split_test_name, groups_to_verticals): + def _verify_split_test_import(self, target_course_name, source_course_name, split_test_name, groups_to_verticals): # lint-amnesty, pylint: disable=missing-function-docstring module_store = modulestore() target_id = module_store.make_course_key('testX', target_course_name, 'copy_run') import_course_from_xml( diff --git a/cms/djangoapps/contentstore/tests/test_import_draft_order.py b/cms/djangoapps/contentstore/tests/test_import_draft_order.py index 95764ab9b2..f87efc043f 100644 --- a/cms/djangoapps/contentstore/tests/test_import_draft_order.py +++ b/cms/djangoapps/contentstore/tests/test_import_draft_order.py @@ -14,7 +14,7 @@ TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT # This test is in the CMS module because the test configuration to use a draft # modulestore is dependent on django. -class DraftReorderTestCase(ModuleStoreTestCase): +class DraftReorderTestCase(ModuleStoreTestCase): # lint-amnesty, pylint: disable=missing-class-docstring def test_order(self): """ diff --git a/cms/djangoapps/contentstore/tests/test_libraries.py b/cms/djangoapps/contentstore/tests/test_libraries.py index f387764916..27edd08d24 100644 --- a/cms/djangoapps/contentstore/tests/test_libraries.py +++ b/cms/djangoapps/contentstore/tests/test_libraries.py @@ -41,7 +41,7 @@ class LibraryTestCase(ModuleStoreTestCase): """ def setUp(self): - super(LibraryTestCase, self).setUp() + super(LibraryTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory(password=self.user_password, is_staff=True) self.client = AjaxEnabledTestClient() @@ -504,7 +504,7 @@ class TestLibraryAccess(LibraryTestCase): def setUp(self): """ Create a library, staff user, and non-staff user """ - super(TestLibraryAccess, self).setUp() + super(TestLibraryAccess, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.non_staff_user_password = 'foo' self.non_staff_user = UserFactory(password=self.non_staff_user_password, is_staff=False) @@ -544,7 +544,7 @@ class TestLibraryAccess(LibraryTestCase): Log out when done each test """ self.client.logout() - super(TestLibraryAccess, self).tearDown() + super(TestLibraryAccess, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments def test_creation(self): """ @@ -837,7 +837,7 @@ class TestOverrides(LibraryTestCase): """ def setUp(self): - super(TestOverrides, self).setUp() + super(TestOverrides, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.original_display_name = "A Problem Block" self.original_weight = 1 @@ -1022,7 +1022,7 @@ class TestIncompatibleModuleStore(LibraryTestCase): """ def setUp(self): - super(TestIncompatibleModuleStore, self).setUp() + super(TestIncompatibleModuleStore, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Create a course in an incompatible modulestore. with modulestore().default_store(ModuleStoreEnum.Type.mongo): self.course = CourseFactory.create() diff --git a/cms/djangoapps/contentstore/tests/test_permissions.py b/cms/djangoapps/contentstore/tests/test_permissions.py index 210c8f0bcb..4a5e005c9a 100644 --- a/cms/djangoapps/contentstore/tests/test_permissions.py +++ b/cms/djangoapps/contentstore/tests/test_permissions.py @@ -5,7 +5,7 @@ Test CRUD for authorization. import copy -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from six.moves import range from cms.djangoapps.contentstore.tests.utils import AjaxEnabledTestClient @@ -25,7 +25,7 @@ class TestCourseAccess(ModuleStoreTestCase): Create a pool of users w/o granting them any permissions """ - super(TestCourseAccess, self).setUp() + super(TestCourseAccess, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.client = AjaxEnabledTestClient() self.client.login(username=self.user.username, password=self.user_password) @@ -94,7 +94,7 @@ class TestCourseAccess(ModuleStoreTestCase): user = users.pop() group.add_users(user) user_by_role[role].append(user) - self.assertTrue(auth.has_course_author_access(user, self.course_key), "{} does not have access".format(user)) + self.assertTrue(auth.has_course_author_access(user, self.course_key), "{} does not have access".format(user)) # lint-amnesty, pylint: disable=line-too-long course_team_url = reverse_course_url('course_team_handler', self.course_key) response = self.client.get_html(course_team_url) @@ -132,4 +132,4 @@ class TestCourseAccess(ModuleStoreTestCase): auth.remove_users(self.user, role(self.course_key.org), user) else: auth.remove_users(self.user, role(self.course_key), user) - self.assertFalse(auth.has_course_author_access(user, self.course_key), u"{} remove didn't work".format(user)) + self.assertFalse(auth.has_course_author_access(user, self.course_key), u"{} remove didn't work".format(user)) # lint-amnesty, pylint: disable=line-too-long diff --git a/cms/djangoapps/contentstore/tests/test_proctoring.py b/cms/djangoapps/contentstore/tests/test_proctoring.py index 1df4e6a6b7..aedb929b08 100644 --- a/cms/djangoapps/contentstore/tests/test_proctoring.py +++ b/cms/djangoapps/contentstore/tests/test_proctoring.py @@ -28,7 +28,7 @@ class TestProctoredExams(ModuleStoreTestCase): """ Initial data setup """ - super(TestProctoredExams, self).setUp() + super(TestProctoredExams, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create( org='edX', diff --git a/cms/djangoapps/contentstore/tests/test_signals.py b/cms/djangoapps/contentstore/tests/test_signals.py index c92928808b..ae81839a3f 100644 --- a/cms/djangoapps/contentstore/tests/test_signals.py +++ b/cms/djangoapps/contentstore/tests/test_signals.py @@ -17,7 +17,7 @@ class LockedTest(ModuleStoreTestCase): """Test class to verify locking of mocked resources""" def setUp(self): - super(LockedTest, self).setUp() + super(LockedTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create( org='edx', name='course', diff --git a/cms/djangoapps/contentstore/tests/test_tasks.py b/cms/djangoapps/contentstore/tests/test_tasks.py index 1239f85373..8d927a0bad 100644 --- a/cms/djangoapps/contentstore/tests/test_tasks.py +++ b/cms/djangoapps/contentstore/tests/test_tasks.py @@ -9,7 +9,7 @@ from uuid import uuid4 import mock 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.test.utils import override_settings from opaque_keys.edx.locator import CourseLocator from organizations.models import OrganizationCourse @@ -114,7 +114,7 @@ class ExportLibraryTestCase(LibraryTestCase): @override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE) -class RerunCourseTaskTestCase(CourseTestCase): +class RerunCourseTaskTestCase(CourseTestCase): # lint-amnesty, pylint: disable=missing-class-docstring def _rerun_course(self, old_course_key, new_course_key): CourseRerunState.objects.initiated(old_course_key, new_course_key, self.user, 'Test Re-run') rerun_course(str(old_course_key), str(new_course_key), self.user.id) diff --git a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py index 887a245ea3..b21cc74e24 100644 --- a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py +++ b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py @@ -33,7 +33,7 @@ TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4(). class TestGenerateSubs(unittest.TestCase): """Tests for `generate_subs` function.""" def setUp(self): - super(TestGenerateSubs, self).setUp() + super(TestGenerateSubs, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.source_subs = { 'start': [100, 200, 240, 390, 1000], @@ -138,7 +138,7 @@ class TestSaveSubsToStore(SharedModuleStoreTestCase): cls.content_location_unjsonable = cls.sub_id_to_location(cls.unjsonable_subs_id) def setUp(self): - super(TestSaveSubsToStore, self).setUp() + super(TestSaveSubsToStore, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.addCleanup(self.clear_subs_content) self.clear_subs_content() @@ -188,7 +188,7 @@ class TestYoutubeSubsBase(SharedModuleStoreTestCase): def setUpClass(cls): super(TestYoutubeSubsBase, cls).setUpClass() cls.course = CourseFactory.create( - org=cls.org, number=cls.number, display_name=cls.display_name) + org=cls.org, number=cls.number, display_name=cls.display_name) # lint-amnesty, pylint: disable=no-member @override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE) @@ -280,7 +280,7 @@ class TestDownloadYoutubeSubs(TestYoutubeSubsBase): transcripts_utils.download_youtube_subs(good_youtube_sub, self.course, settings) # Check assets status after importing subtitles. - for subs_id in good_youtube_subs.values(): + for subs_id in good_youtube_subs.values(): # lint-amnesty, pylint: disable=undefined-variable filename = 'subs_{0}.srt.sjson'.format(subs_id) content_location = StaticContent.compute_location( self.course.id, filename @@ -355,7 +355,7 @@ class TestDownloadYoutubeSubs(TestYoutubeSubsBase): ) -class TestGenerateSubsFromSource(TestDownloadYoutubeSubs): +class TestGenerateSubsFromSource(TestDownloadYoutubeSubs): # lint-amnesty, pylint: disable=test-inherits-tests """Tests for `generate_subs_from_source` function.""" def test_success_generating_subs(self): @@ -426,7 +426,7 @@ class TestGenerateSubsFromSource(TestDownloadYoutubeSubs): self.assertEqual(exception_message, "Something wrong with SubRip transcripts file during parsing.") -class TestGenerateSrtFromSjson(TestDownloadYoutubeSubs): +class TestGenerateSrtFromSjson(TestDownloadYoutubeSubs): # lint-amnesty, pylint: disable=test-inherits-tests """Tests for `generate_srt_from_sjson` function.""" def test_success_generating_subs(self): @@ -561,7 +561,7 @@ class TestTranscript(unittest.TestCase): Tests for Transcript class e.g. different transcript conversions. """ def setUp(self): - super(TestTranscript, self).setUp() + super(TestTranscript, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.srt_transcript = textwrap.dedent("""\ 0 @@ -710,7 +710,7 @@ class TestGetTranscript(SharedModuleStoreTestCase): """Tests for `get_transcript` function.""" def setUp(self): - super(TestGetTranscript, self).setUp() + super(TestGetTranscript, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create() diff --git a/cms/djangoapps/contentstore/tests/test_users_default_role.py b/cms/djangoapps/contentstore/tests/test_users_default_role.py index e968fd8cae..eb92b9c308 100644 --- a/cms/djangoapps/contentstore/tests/test_users_default_role.py +++ b/cms/djangoapps/contentstore/tests/test_users_default_role.py @@ -19,7 +19,7 @@ class TestUsersDefaultRole(ModuleStoreTestCase): """ Add a user and a course """ - super(TestUsersDefaultRole, self).setUp() + super(TestUsersDefaultRole, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # create and log in a staff user. self.user = UserFactory(is_staff=True) self.client = AjaxEnabledTestClient() @@ -49,7 +49,7 @@ class TestUsersDefaultRole(ModuleStoreTestCase): Reverse the setup """ self.client.logout() - super(TestUsersDefaultRole, self).tearDown() + super(TestUsersDefaultRole, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments def test_user_forum_default_role_on_course_deletion(self): """ diff --git a/cms/djangoapps/contentstore/tests/test_utils.py b/cms/djangoapps/contentstore/tests/test_utils.py index 28f0d71342..642a379b06 100644 --- a/cms/djangoapps/contentstore/tests/test_utils.py +++ b/cms/djangoapps/contentstore/tests/test_utils.py @@ -168,7 +168,7 @@ class ReleaseDateSourceTest(CourseTestCase): """Tests for finding the source of an xblock's release date.""" def setUp(self): - super(ReleaseDateSourceTest, self).setUp() + super(ReleaseDateSourceTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.chapter = ItemFactory.create(category='chapter', parent_location=self.course.location) self.sequential = ItemFactory.create(category='sequential', parent_location=self.chapter.location) @@ -222,7 +222,7 @@ class StaffLockTest(CourseTestCase): """Base class for testing staff lock functions.""" def setUp(self): - super(StaffLockTest, self).setUp() + super(StaffLockTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.chapter = ItemFactory.create(category='chapter', parent_location=self.course.location) self.sequential = ItemFactory.create(category='sequential', parent_location=self.chapter.location) @@ -332,7 +332,7 @@ class GroupVisibilityTest(CourseTestCase): """ def setUp(self): - super(GroupVisibilityTest, self).setUp() + super(GroupVisibilityTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments chapter = ItemFactory.create(category='chapter', parent_location=self.course.location) sequential = ItemFactory.create(category='sequential', parent_location=chapter.location) @@ -432,7 +432,7 @@ class GetUserPartitionInfoTest(ModuleStoreTestCase): def setUp(self): """Create a dummy course. """ - super(GetUserPartitionInfoTest, self).setUp() + super(GetUserPartitionInfoTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory() self.block = ItemFactory.create(category="problem", parent_location=self.course.location) diff --git a/cms/djangoapps/contentstore/tests/test_video_utils.py b/cms/djangoapps/contentstore/tests/test_video_utils.py index f5abd76dbf..71e9643fad 100644 --- a/cms/djangoapps/contentstore/tests/test_video_utils.py +++ b/cms/djangoapps/contentstore/tests/test_video_utils.py @@ -59,7 +59,7 @@ class ScrapeVideoThumbnailsTestCase(CourseTestCase): """ def setUp(self): - super(ScrapeVideoThumbnailsTestCase, self).setUp() + super(ScrapeVideoThumbnailsTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments course_ids = [six.text_type(self.course.id)] profiles = ['youtube'] created = datetime.now(pytz.utc) @@ -214,7 +214,7 @@ class ScrapeVideoThumbnailsTestCase(CourseTestCase): mocked_responses = [] for resolution in YOUTUBE_THUMBNAIL_SIZES: mocked_content = resolutions.get(resolution, '') - error_response = False if mocked_content else True + error_response = False if mocked_content else True # lint-amnesty, pylint: disable=simplifiable-if-expression mocked_responses.append(self.mocked_youtube_thumbnail_response(mocked_content, error_response)) return mocked_responses diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index 958d877a69..19837e7136 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -91,7 +91,7 @@ class AuthTestCase(ContentStoreTestCase): ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache'] def setUp(self): - super(AuthTestCase, self).setUp() + super(AuthTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.email = 'a@b.com' self.pw = 'xyz' @@ -191,7 +191,7 @@ class ForumTestCase(CourseTestCase): def setUp(self): """ Creates the test course. """ - super(ForumTestCase, self).setUp() + super(ForumTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create(org='testX', number='727', display_name='Forum Course') def set_blackout_dates(self, blackout_dates): @@ -242,7 +242,7 @@ class CourseKeyVerificationTestCase(CourseTestCase): """ Create test course. """ - super(CourseKeyVerificationTestCase, self).setUp() + super(CourseKeyVerificationTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create(org='edX', number='test_course_key', display_name='Test Course') @data(('edX/test_course_key/Test_Course', 200), ('garbage:edX+test_course_key+Test_Course', 404)) diff --git a/cms/djangoapps/contentstore/tests/utils.py b/cms/djangoapps/contentstore/tests/utils.py index 0c9dc771a7..f739e6bf86 100644 --- a/cms/djangoapps/contentstore/tests/utils.py +++ b/cms/djangoapps/contentstore/tests/utils.py @@ -8,7 +8,7 @@ import textwrap 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.test.client import Client from mock import Mock from opaque_keys.edx.keys import AssetKey, CourseKey @@ -84,7 +84,7 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase): afterwards. """ - super(CourseTestCase, self).setUp() + super(CourseTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.client = AjaxEnabledTestClient() self.client.login(username=self.user.username, password=self.user_password) @@ -285,8 +285,8 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase): course2_items = self.store.get_items(course2_id) self.assertGreater(len(course1_items), 0) # ensure it found content instead of [] == [] if len(course1_items) != len(course2_items): - course1_block_ids = set([item.location.block_id for item in course1_items]) - course2_block_ids = set([item.location.block_id for item in course2_items]) + course1_block_ids = set([item.location.block_id for item in course1_items]) # lint-amnesty, pylint: disable=consider-using-set-comprehension + course2_block_ids = set([item.location.block_id for item in course2_items]) # lint-amnesty, pylint: disable=consider-using-set-comprehension raise AssertionError( u"Course1 extra blocks: {}; course2 extra blocks: {}".format( course1_block_ids - course2_block_ids, course2_block_ids - course1_block_ids diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index aed8c315ef..de69f94654 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -99,7 +99,7 @@ def _remove_instructors(course_key): try: remove_all_instructors(course_key) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except log.error(u"Error in deleting course groups for {0}: {1}".format(course_key, err)) @@ -191,7 +191,7 @@ def is_currently_visible_to_students(xblock): return False # Check start date - if 'detached' not in published._class_tags and published.start is not None: + if 'detached' not in published._class_tags and published.start is not None: # lint-amnesty, pylint: disable=protected-access return datetime.now(UTC) > published.start # No start date, so it's always visible diff --git a/cms/djangoapps/contentstore/video_utils.py b/cms/djangoapps/contentstore/video_utils.py index c05eda9684..887b9d2ac3 100644 --- a/cms/djangoapps/contentstore/video_utils.py +++ b/cms/djangoapps/contentstore/video_utils.py @@ -117,7 +117,7 @@ def validate_and_update_video_image(course_key_string, edx_video_id, image_file, update_video_image(edx_video_id, course_key_string, image_file, image_filename) LOGGER.info( - u'VIDEOS: Scraping youtube video thumbnail for edx_video_id [%s] in course [%s]', edx_video_id, course_key_string + u'VIDEOS: Scraping youtube video thumbnail for edx_video_id [%s] in course [%s]', edx_video_id, course_key_string # lint-amnesty, pylint: disable=line-too-long ) diff --git a/cms/djangoapps/contentstore/views/__init__.py b/cms/djangoapps/contentstore/views/__init__.py index 896789407d..1263976c7b 100644 --- a/cms/djangoapps/contentstore/views/__init__.py +++ b/cms/djangoapps/contentstore/views/__init__.py @@ -3,7 +3,7 @@ from .assets import * from .checklists import * from .component import * -from .course import * +from .course import * # lint-amnesty, pylint: disable=redefined-builtin from .entrance_exam import * from .error import * from .export_git import * diff --git a/cms/djangoapps/contentstore/views/assets.py b/cms/djangoapps/contentstore/views/assets.py index 7974041b56..acfb8b7187 100644 --- a/cms/djangoapps/contentstore/views/assets.py +++ b/cms/djangoapps/contentstore/views/assets.py @@ -150,7 +150,7 @@ def _assets_json(request, course_key): assets, total_count = _get_assets_for_page(course_key, query_options) - if request_options['requested_page'] > 0 and first_asset_to_display_index >= total_count and total_count > 0: + if request_options['requested_page'] > 0 and first_asset_to_display_index >= total_count and total_count > 0: # lint-amnesty, pylint: disable=chained-comparison _update_options_to_requery_final_page(query_options, total_count) current_page = query_options['current_page'] first_asset_to_display_index = _get_first_asset_index(current_page, requested_page_size) @@ -432,7 +432,7 @@ def _upload_asset(request, course_key): }) -def _get_error_if_course_does_not_exist(course_key): +def _get_error_if_course_does_not_exist(course_key): # lint-amnesty, pylint: disable=missing-function-docstring try: modulestore().get_course(course_key) except ItemNotFoundError: @@ -440,7 +440,7 @@ def _get_error_if_course_does_not_exist(course_key): return HttpResponseBadRequest() -def _get_file_metadata_as_dictionary(upload_file): +def _get_file_metadata_as_dictionary(upload_file): # lint-amnesty, pylint: disable=missing-function-docstring # compute a 'filename' which is similar to the location formatting; we're # using the 'filename' nomenclature since we're using a FileSystem paradigm # here; we're just imposing the Location string formatting expectations to @@ -564,15 +564,15 @@ def delete_asset(course_key, asset_key): del_cached_content(content.location) -def _check_existence_and_get_asset_content(asset_key): +def _check_existence_and_get_asset_content(asset_key): # lint-amnesty, pylint: disable=missing-function-docstring try: content = contentstore().find(asset_key) return content except NotFoundError: - raise AssetNotFoundException + raise AssetNotFoundException # lint-amnesty, pylint: disable=raise-missing-from -def _delete_thumbnail(thumbnail_location, course_key, asset_key): +def _delete_thumbnail(thumbnail_location, course_key, asset_key): # lint-amnesty, pylint: disable=missing-function-docstring if thumbnail_location is not None: # We are ignoring the value of the thumbnail_location-- we only care whether diff --git a/cms/djangoapps/contentstore/views/certificates.py b/cms/djangoapps/contentstore/views/certificates.py index 7b16ba6d36..97ba8ad289 100644 --- a/cms/djangoapps/contentstore/views/certificates.py +++ b/cms/djangoapps/contentstore/views/certificates.py @@ -113,14 +113,14 @@ class CertificateException(Exception): """ Base exception for Certificates workflows """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class CertificateValidationError(CertificateException): """ An exception raised when certificate information is invalid. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class CertificateManager(object): @@ -136,7 +136,7 @@ class CertificateManager(object): try: certificate = json.loads(json_string) except ValueError: - raise CertificateValidationError(_("invalid JSON")) + raise CertificateValidationError(_("invalid JSON")) # lint-amnesty, pylint: disable=raise-missing-from # Include the data contract version certificate["version"] = CERTIFICATE_SCHEMA_VERSION # Ensure a signatories list is always returned diff --git a/cms/djangoapps/contentstore/views/checklists.py b/cms/djangoapps/contentstore/views/checklists.py index a04cf8ec28..2fa27871d0 100644 --- a/cms/djangoapps/contentstore/views/checklists.py +++ b/cms/djangoapps/contentstore/views/checklists.py @@ -1,3 +1,4 @@ +# lint-amnesty, pylint: disable=missing-module-docstring from django.contrib.auth.decorators import login_required from django.core.exceptions import PermissionDenied from django.views.decorators.csrf import ensure_csrf_cookie diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index dda94a072e..01b9d4ac1e 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -113,7 +113,7 @@ def container_handler(request, usage_key_string): try: usage_key = UsageKey.from_string(usage_key_string) except InvalidKeyError: # Raise Http404 on invalid 'usage_key_string' - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from with modulestore().bulk_operations(usage_key.course_key): try: course, xblock, lms_link, preview_lms_link = _get_item_in_course(request, usage_key) @@ -208,7 +208,7 @@ def container_handler(request, usage_key_string): return HttpResponseBadRequest("Only supports HTML requests") -def get_component_templates(courselike, library=False): +def get_component_templates(courselike, library=False): # lint-amnesty, pylint: disable=too-many-statements """ Returns the applicable component templates that can be used by the specified course or library. """ @@ -298,7 +298,7 @@ def get_component_templates(courselike, library=False): # Content Libraries currently don't allow opting in to unsupported xblocks/problem types. allow_unsupported = getattr(courselike, "allow_unsupported_xblocks", False) - for category in component_types: + for category in component_types: # lint-amnesty, pylint: disable=too-many-nested-blocks authorable_variations = authorable_xblocks(allow_unsupported=allow_unsupported, name=category) support_level_without_template = component_support_level(authorable_variations, category) templates_for_category = [] @@ -338,7 +338,7 @@ def get_component_templates(courselike, library=False): templates_for_category.append( create_template_dict( - _(template['metadata'].get('display_name')), + _(template['metadata'].get('display_name')), # lint-amnesty, pylint: disable=translation-of-non-string category, support_level_with_template, template_id, @@ -504,7 +504,7 @@ def component_handler(request, usage_key_string, handler, suffix=''): resp = handler_descriptor.handle(handler, req, suffix) except NoSuchHandlerError: log.info(u"XBlock %s attempted to access missing handler %r", handler_descriptor, handler, exc_info=True) - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from # unintentional update to handle any side effects of handle call # could potentially be updating actual course data or simply caching its values diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index cdb5fe25dd..9a4887a4d0 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -133,7 +133,7 @@ class AccessListFallback(Exception): An exception that is raised whenever we need to `fall back` to fetching *all* courses available to a user, rather than using a shorter method (i.e. fetching by group) """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def get_course_and_check_access(course_key, user, depth=0): @@ -289,7 +289,7 @@ def course_handler(request, course_key_string=None): else: return HttpResponseNotFound() except InvalidKeyError: - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from @login_required @@ -357,7 +357,7 @@ def _course_outline_json(request, course_module): return create_xblock_info( course_module, include_child_info=True, - course_outline=False if is_concise else True, + course_outline=False if is_concise else True, # lint-amnesty, pylint: disable=simplifiable-if-expression include_children_predicate=include_children_predicate, is_concise=is_concise, user=request.user @@ -531,8 +531,8 @@ def course_listing(request): u'org': uca.course_key.org, u'number': uca.course_key.course, u'run': uca.course_key.run, - u'is_failed': True if uca.state == CourseRerunUIStateManager.State.FAILED else False, - u'is_in_progress': True if uca.state == CourseRerunUIStateManager.State.IN_PROGRESS else False, + u'is_failed': True if uca.state == CourseRerunUIStateManager.State.FAILED else False, # lint-amnesty, pylint: disable=simplifiable-if-expression + u'is_in_progress': True if uca.state == CourseRerunUIStateManager.State.IN_PROGRESS else False, # lint-amnesty, pylint: disable=simplifiable-if-expression u'dismiss_link': reverse_course_url( u'course_notifications_handler', uca.course_key, @@ -679,7 +679,7 @@ def course_index(request, course_key): 'lms_link': lms_link, 'sections': sections, 'course_structure': course_structure, - 'initial_state': course_outline_initial_state(locator_to_show, course_structure) if locator_to_show else None, + 'initial_state': course_outline_initial_state(locator_to_show, course_structure) if locator_to_show else None, # lint-amnesty, pylint: disable=line-too-long 'rerun_notification_id': current_action.id if current_action else None, 'course_release_date': course_release_date, 'settings_url': settings_url, @@ -893,7 +893,7 @@ def create_new_course(user, org, number, run, fields): try: org_data = ensure_organization(org) except InvalidOrganizationException: - raise ValidationError(_( + raise ValidationError(_( # lint-amnesty, pylint: disable=raise-missing-from 'You must link this course to an organization in order to continue. Organization ' 'you selected does not exist in the system, you will need to add it to the system' )) @@ -985,7 +985,7 @@ def course_info_handler(request, course_key_string): try: course_key = CourseKey.from_string(course_key_string) except InvalidKeyError: - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from with modulestore().bulk_operations(course_key): course_module = get_course_and_check_access(course_key, request.user) @@ -1041,7 +1041,7 @@ def course_info_update_handler(request, course_key_string, provided_id=None): elif request.method == 'DELETE': try: return JsonResponse(delete_course_update(usage_key, request.json, provided_id, request.user)) - except: + except: # lint-amnesty, pylint: disable=bare-except return HttpResponseBadRequest( "Failed to delete", content_type="text/plain" @@ -1050,7 +1050,7 @@ def course_info_update_handler(request, course_key_string, provided_id=None): elif request.method in ('POST', 'PUT'): try: return JsonResponse(update_course_updates(usage_key, request.json, provided_id, request.user)) - except: + except: # lint-amnesty, pylint: disable=bare-except return HttpResponseBadRequest( "Failed to save", content_type="text/plain" @@ -1061,7 +1061,7 @@ def course_info_update_handler(request, course_key_string, provided_id=None): @ensure_csrf_cookie @require_http_methods(("GET", "PUT", "POST")) @expect_json -def settings_handler(request, course_key_string): +def settings_handler(request, course_key_string): # lint-amnesty, pylint: disable=too-many-statements """ Course settings for dates and about pages GET @@ -1156,7 +1156,7 @@ def settings_handler(request, course_key_string): # if 'minimum_grade_credit' of a course is not set or 0 then # show warning message to course author. - show_min_grade_warning = False if course_module.minimum_grade_credit > 0 else True + show_min_grade_warning = False if course_module.minimum_grade_credit > 0 else True # lint-amnesty, pylint: disable=simplifiable-if-expression settings_context.update( { 'is_credit_course': True, @@ -1185,7 +1185,7 @@ def settings_handler(request, course_key_string): set_prerequisite_courses(course_key, prerequisite_course_keys) else: # None is chosen, so remove the course prerequisites - course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship="requires") + course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship="requires") # lint-amnesty, pylint: disable=line-too-long for milestone in course_milestones: remove_prerequisite_course(course_key, milestone) @@ -1412,7 +1412,7 @@ def advanced_settings_handler(request, course_key_string): class TextbookValidationError(Exception): "An error thrown when a textbook input is invalid" - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def validate_textbooks_json(text): @@ -1424,7 +1424,7 @@ def validate_textbooks_json(text): try: textbooks = json.loads(text) except ValueError: - raise TextbookValidationError("invalid JSON") + raise TextbookValidationError("invalid JSON") # lint-amnesty, pylint: disable=raise-missing-from if not isinstance(textbooks, (list, tuple)): raise TextbookValidationError("must be JSON list") for textbook in textbooks: @@ -1447,7 +1447,7 @@ def validate_textbook_json(textbook): try: textbook = json.loads(textbook) except ValueError: - raise TextbookValidationError("invalid JSON") + raise TextbookValidationError("invalid JSON") # lint-amnesty, pylint: disable=raise-missing-from if not isinstance(textbook, dict): raise TextbookValidationError("must be JSON object") if not textbook.get("tab_title"): @@ -1768,7 +1768,7 @@ def group_configurations_detail_handler(request, course_key_string, group_config if request.method in ('POST', 'PUT'): # can be either and sometimes django is rewriting one to the other try: - new_configuration = GroupConfiguration(request.body, course, group_configuration_id).get_user_partition() + new_configuration = GroupConfiguration(request.body, course, group_configuration_id).get_user_partition() # lint-amnesty, pylint: disable=line-too-long except GroupConfigurationsValidationError as err: return JsonResponse({"error": text_type(err)}, status=400) diff --git a/cms/djangoapps/contentstore/views/entrance_exam.py b/cms/djangoapps/contentstore/views/entrance_exam.py index 90528c05fa..110609edb4 100644 --- a/cms/djangoapps/contentstore/views/entrance_exam.py +++ b/cms/djangoapps/contentstore/views/entrance_exam.py @@ -178,7 +178,7 @@ def _get_entrance_exam(request, course_key): return HttpResponse(status=404) try: exam_descriptor = modulestore().get_item(exam_key) - return HttpResponse( + return HttpResponse( # lint-amnesty, pylint: disable=http-response-with-content-type-json dump_js_escaped_json({'locator': six.text_type(exam_descriptor.location)}), status=200, content_type='application/json') except ItemNotFoundError: @@ -235,7 +235,7 @@ def _delete_entrance_exam(request, course_key): return HttpResponse(status=204) -def add_entrance_exam_milestone(course_id, x_block): +def add_entrance_exam_milestone(course_id, x_block): # lint-amnesty, pylint: disable=missing-function-docstring # Add an entrance exam milestone if one does not already exist for given xBlock # As this is a standalone method for entrance exam, We should check that given xBlock should be an entrance exam. if x_block.is_entrance_exam: @@ -245,7 +245,7 @@ def add_entrance_exam_milestone(course_id, x_block): course_id ) milestones = milestones_helpers.get_milestones(milestone_namespace) - if len(milestones): + if len(milestones): # lint-amnesty, pylint: disable=len-as-condition milestone = milestones[0] else: description = u'Autogenerated during {} entrance exam creation.'.format(six.text_type(course_id)) diff --git a/cms/djangoapps/contentstore/views/error.py b/cms/djangoapps/contentstore/views/error.py index 9fd2734b67..82d03f7c92 100644 --- a/cms/djangoapps/contentstore/views/error.py +++ b/cms/djangoapps/contentstore/views/error.py @@ -1,3 +1,4 @@ +# lint-amnesty, pylint: disable=missing-module-docstring import functools from django.http import HttpResponse, HttpResponseNotFound, HttpResponseServerError @@ -19,7 +20,7 @@ def jsonable_error(status=500, message="The Studio servers encountered an error" def inner(request, *args, **kwargs): if request.is_ajax(): content = dump_js_escaped_json({"error": message}) - return HttpResponse(content, content_type="application/json", + return HttpResponse(content, content_type="application/json", # lint-amnesty, pylint: disable=http-response-with-content-type-json status=status) else: return func(request, *args, **kwargs) @@ -28,7 +29,7 @@ def jsonable_error(status=500, message="The Studio servers encountered an error" @jsonable_error(404, "Resource not found") -def not_found(request, exception): +def not_found(request, exception): # lint-amnesty, pylint: disable=unused-argument return render_to_response('error.html', {'error': '404'}) @@ -39,7 +40,7 @@ def server_error(request): @fix_crum_request @jsonable_error(404, "Resource not found") -def render_404(request, exception): +def render_404(request, exception): # lint-amnesty, pylint: disable=unused-argument return HttpResponseNotFound(render_to_string('404.html', {}, request=request)) diff --git a/cms/djangoapps/contentstore/views/exception.py b/cms/djangoapps/contentstore/views/exception.py index 3cb3d7a396..98b26286b9 100644 --- a/cms/djangoapps/contentstore/views/exception.py +++ b/cms/djangoapps/contentstore/views/exception.py @@ -7,11 +7,11 @@ class AssetNotFoundException(Exception): """ Raised when asset not found """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AssetSizeTooLargeException(Exception): """ Raised when the size of an uploaded asset exceeds the maximum size limit. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass diff --git a/cms/djangoapps/contentstore/views/helpers.py b/cms/djangoapps/contentstore/views/helpers.py index bf563b412b..609d8e497e 100644 --- a/cms/djangoapps/contentstore/views/helpers.py +++ b/cms/djangoapps/contentstore/views/helpers.py @@ -142,7 +142,7 @@ def xblock_type_display_name(xblock, default_display_name=None): return _('Unit') component_class = XBlock.load_class(category, select=settings.XBLOCK_SELECT_FUNCTION) if hasattr(component_class, 'display_name') and component_class.display_name.default: - return _(component_class.display_name.default) + return _(component_class.display_name.default) # lint-amnesty, pylint: disable=translation-of-non-string else: return default_display_name diff --git a/cms/djangoapps/contentstore/views/import_export.py b/cms/djangoapps/contentstore/views/import_export.py index 55af032318..0a1f1b809d 100644 --- a/cms/djangoapps/contentstore/views/import_export.py +++ b/cms/djangoapps/contentstore/views/import_export.py @@ -1,4 +1,4 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured These views handle all actions in Studio related to import and exporting of courses """ @@ -83,7 +83,7 @@ def import_handler(request, course_key_string): raise PermissionDenied() if 'application/json' in request.META.get('HTTP_ACCEPT', 'application/json'): - if request.method == 'GET': + if request.method == 'GET': # lint-amnesty, pylint: disable=no-else-raise raise NotImplementedError('coming soon') else: return _write_chunk(request, courselike_key) @@ -181,7 +181,7 @@ def _write_chunk(request, courselike_key): elif size > int(content_range['stop']) and size == int(content_range['end']): return JsonResponse({'ImportStatus': 1}) - with open(temp_filepath, mode) as temp_file: # pylint: disable=W6005 + with open(temp_filepath, mode) as temp_file: for chunk in request.FILES['course-data'].chunks(): temp_file.write(chunk) @@ -201,7 +201,7 @@ def _write_chunk(request, courselike_key): }) log.info(u"Course import %s: Upload complete", courselike_key) - with open(temp_filepath, 'rb') as local_file: # pylint: disable=W6005 + with open(temp_filepath, 'rb') as local_file: django_file = File(local_file) storage_path = course_import_export_storage.save(u'olx_import/' + filename, django_file) import_olx.delay( @@ -437,7 +437,7 @@ def export_output_handler(request, course_key_string): tarball = course_import_export_storage.open(artifact.file.name) return send_tarball(tarball, artifact.file.storage.size(artifact.file.name)) except UserTaskArtifact.DoesNotExist: - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from finally: if artifact: artifact.file.close() diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index d8bcf7bca6..d9ed71c0ae 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -1,7 +1,7 @@ """Views for items (modules).""" -import hashlib +import hashlib # lint-amnesty, pylint: disable=unused-import import logging from collections import OrderedDict from datetime import datetime @@ -10,7 +10,7 @@ from uuid import uuid4 from django.conf import settings from django.contrib.auth.decorators import login_required -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.http import Http404, HttpResponse, HttpResponseBadRequest from django.utils.translation import ugettext as _ @@ -528,7 +528,7 @@ def _update_with_callback(xblock, user, old_metadata=None, old_content=None): return modulestore().update_item(xblock, user.id) -def _save_xblock(user, xblock, data=None, children_strings=None, metadata=None, nullout=None, +def _save_xblock(user, xblock, data=None, children_strings=None, metadata=None, nullout=None, # lint-amnesty, pylint: disable=too-many-statements grader_type=None, is_prereq=None, prereq_usage_key=None, prereq_min_score=None, prereq_min_completion=None, publish=None, fields=None): """ @@ -1124,7 +1124,7 @@ def _get_gating_info(course, xblock): return info -def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=False, include_child_info=False, +def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=False, include_child_info=False, # lint-amnesty, pylint: disable=too-many-statements course_outline=False, include_children_predicate=NEVER, parent_xblock=None, graders=None, user=None, course=None, is_concise=False): """ diff --git a/cms/djangoapps/contentstore/views/organization.py b/cms/djangoapps/contentstore/views/organization.py index d0dd98e5b0..7ece98201a 100644 --- a/cms/djangoapps/contentstore/views/organization.py +++ b/cms/djangoapps/contentstore/views/organization.py @@ -18,8 +18,8 @@ class OrganizationListView(View): """ @method_decorator(login_required) - def get(self, request, *args, **kwargs): + def get(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument """Returns organization list as json.""" organizations = get_organizations() org_names_list = [(org["short_name"]) for org in organizations] - return HttpResponse(dump_js_escaped_json(org_names_list), content_type='application/json; charset=utf-8') + return HttpResponse(dump_js_escaped_json(org_names_list), content_type='application/json; charset=utf-8') # lint-amnesty, pylint: disable=http-response-with-content-type-json diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index fde3acbdc0..49569ee145 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -1,4 +1,4 @@ - +# lint-amnesty, pylint: disable=missing-module-docstring import logging from functools import partial @@ -74,11 +74,11 @@ def preview_handler(request, usage_key_string, handler, suffix=''): except NoSuchHandlerError: log.exception(u"XBlock %s attempted to access missing handler %r", instance, handler) - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from except NotFoundError: log.exception("Module indicating to user that request doesn't exist") - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from except ProcessingError: log.warning("Module raised an error while processing AJAX request", @@ -121,7 +121,7 @@ class PreviewModuleSystem(ModuleSystem): # pylint: disable=abstract-method # (see https://openedx.atlassian.net/browse/TE-811) return [ aside_type - for aside_type in super(PreviewModuleSystem, self).applicable_aside_types(block) + for aside_type in super(PreviewModuleSystem, self).applicable_aside_types(block) # lint-amnesty, pylint: disable=super-with-arguments if aside_type != 'acid_aside' ] @@ -285,7 +285,7 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False): is_reorderable = _is_xblock_reorderable(xblock, context) selected_groups_label = get_visibility_partition_info(xblock)['selected_groups_label'] if selected_groups_label: - selected_groups_label = _(u'Access restricted to: {list_of_groups}').format(list_of_groups=selected_groups_label) + selected_groups_label = _(u'Access restricted to: {list_of_groups}').format(list_of_groups=selected_groups_label) # lint-amnesty, pylint: disable=line-too-long course = modulestore().get_course(xblock.location.course_key) template_context = { 'xblock_context': context, diff --git a/cms/djangoapps/contentstore/views/session_kv_store.py b/cms/djangoapps/contentstore/views/session_kv_store.py index 34eb146913..7654f78a06 100644 --- a/cms/djangoapps/contentstore/views/session_kv_store.py +++ b/cms/djangoapps/contentstore/views/session_kv_store.py @@ -10,7 +10,7 @@ def stringify(key): return repr(tuple(key)) -class SessionKeyValueStore(KeyValueStore): +class SessionKeyValueStore(KeyValueStore): # lint-amnesty, pylint: disable=missing-class-docstring def __init__(self, request): self._session = request.session diff --git a/cms/djangoapps/contentstore/views/tabs.py b/cms/djangoapps/contentstore/views/tabs.py index 11438ae3e4..b299a760e1 100644 --- a/cms/djangoapps/contentstore/views/tabs.py +++ b/cms/djangoapps/contentstore/views/tabs.py @@ -48,7 +48,7 @@ def tabs_handler(request, course_key_string): course_item = modulestore().get_course(course_key) if 'application/json' in request.META.get('HTTP_ACCEPT', 'application/json'): - if request.method == 'GET': + if request.method == 'GET': # lint-amnesty, pylint: disable=no-else-raise raise NotImplementedError('coming soon') else: if 'tabs' in request.json: diff --git a/cms/djangoapps/contentstore/views/tests/test_access.py b/cms/djangoapps/contentstore/views/tests/test_access.py index fa7cff61cd..5b171173c8 100644 --- a/cms/djangoapps/contentstore/views/tests/test_access.py +++ b/cms/djangoapps/contentstore/views/tests/test_access.py @@ -3,7 +3,7 @@ Tests access.py """ -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.test import TestCase from opaque_keys.edx.locator import CourseLocator @@ -20,7 +20,7 @@ class RolesTest(TestCase): """ def setUp(self): """ Test case setup """ - super(RolesTest, self).setUp() + super(RolesTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.global_admin = AdminFactory() self.instructor = User.objects.create_user('testinstructor', 'testinstructor+courses@edx.org', 'foo') diff --git a/cms/djangoapps/contentstore/views/tests/test_assets.py b/cms/djangoapps/contentstore/views/tests/test_assets.py index 872922a7f0..96ae66cad5 100644 --- a/cms/djangoapps/contentstore/views/tests/test_assets.py +++ b/cms/djangoapps/contentstore/views/tests/test_assets.py @@ -43,7 +43,7 @@ class AssetsTestCase(CourseTestCase): Parent class for all asset tests. """ def setUp(self): - super(AssetsTestCase, self).setUp() + super(AssetsTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse_course_url('assets_handler', self.course.id) def upload_asset(self, name="asset-1", asset_type='text'): @@ -343,7 +343,7 @@ class UploadTestCase(AssetsTestCase): Unit tests for uploading a file """ def setUp(self): - super(UploadTestCase, self).setUp() + super(UploadTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse_course_url('assets_handler', self.course.id) def test_happy_path(self): @@ -378,7 +378,7 @@ class DownloadTestCase(AssetsTestCase): Unit tests for downloading a file. """ def setUp(self): - super(DownloadTestCase, self).setUp() + super(DownloadTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse_course_url('assets_handler', self.course.id) # First, upload something. self.asset_name = 'download_test' @@ -502,7 +502,7 @@ class DeleteAssetTestCase(AssetsTestCase): """ def setUp(self): """ Scaffolding """ - super(DeleteAssetTestCase, self).setUp() + super(DeleteAssetTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse_course_url('assets_handler', self.course.id) # First, upload something. self.asset_name = 'delete_test' diff --git a/cms/djangoapps/contentstore/views/tests/test_certificates.py b/cms/djangoapps/contentstore/views/tests/test_certificates.py index 4b36da9212..24ca0b4628 100644 --- a/cms/djangoapps/contentstore/views/tests/test_certificates.py +++ b/cms/djangoapps/contentstore/views/tests/test_certificates.py @@ -208,11 +208,11 @@ class CertificatesListHandlerTestCase( Test cases for certificates_list_handler. """ - def setUp(self): + def setUp(self): # lint-amnesty, pylint: disable=arguments-differ """ Set up CertificatesListHandlerTestCase. """ - super(CertificatesListHandlerTestCase, self).setUp('cms.djangoapps.contentstore.views.certificates.tracker') + super(CertificatesListHandlerTestCase, self).setUp('cms.djangoapps.contentstore.views.certificates.tracker') # lint-amnesty, pylint: disable=super-with-arguments self.reset_urls() def _url(self): @@ -437,7 +437,7 @@ class CertificatesDetailHandlerTestCase( """ Set up CertificatesDetailHandlerTestCase. """ - super(CertificatesDetailHandlerTestCase, self).setUp('cms.djangoapps.contentstore.views.certificates.tracker') + super(CertificatesDetailHandlerTestCase, self).setUp('cms.djangoapps.contentstore.views.certificates.tracker') # lint-amnesty, pylint: disable=super-with-arguments self.reset_urls() def _url(self, cid=-1): diff --git a/cms/djangoapps/contentstore/views/tests/test_container_page.py b/cms/djangoapps/contentstore/views/tests/test_container_page.py index ff5d9cc16a..f1c82a60e2 100644 --- a/cms/djangoapps/contentstore/views/tests/test_container_page.py +++ b/cms/djangoapps/contentstore/views/tests/test_container_page.py @@ -31,7 +31,7 @@ class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase): reorderable_child_view = 'reorderable_container_child_preview' def setUp(self): - super(ContainerPageTestCase, self).setUp() + super(ContainerPageTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.vertical = self._create_item(self.sequential.location, 'vertical', 'Unit') self.html = self._create_item(self.vertical.location, "html", "HTML") self.child_container = self._create_item(self.vertical.location, 'split_test', 'Split Test') diff --git a/cms/djangoapps/contentstore/views/tests/test_course_index.py b/cms/djangoapps/contentstore/views/tests/test_course_index.py index 4ac5f6cf76..a172ae597a 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_index.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_index.py @@ -44,7 +44,7 @@ class TestCourseIndex(CourseTestCase): """ Add a course with odd characters in the fields """ - super(TestCourseIndex, self).setUp() + super(TestCourseIndex, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # had a problem where index showed course but has_access failed to retrieve it for non-staff self.odd_course = CourseFactory.create( org='test.org_1-2', @@ -75,7 +75,7 @@ class TestCourseIndex(CourseTestCase): self.assertEqual(len(library_tab), 1) # Add a library: - lib1 = LibraryFactory.create() + lib1 = LibraryFactory.create() # lint-amnesty, pylint: disable=unused-variable index_url = '/home/' index_response = self.client.get(index_url, {}, HTTP_ACCEPT='text/html') @@ -329,7 +329,7 @@ class TestCourseIndexArchived(CourseTestCase): """ Add courses with the end date set to various values """ - super(TestCourseIndexArchived, self).setUp() + super(TestCourseIndexArchived, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Base course has no end date (so is active) self.course.end = None @@ -426,7 +426,7 @@ class TestCourseOutline(CourseTestCase): """ Set up the for the course outline tests. """ - super(TestCourseOutline, self).setUp() + super(TestCourseOutline, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.chapter = ItemFactory.create( parent_location=self.course.location, category='chapter', display_name="Week 1" @@ -604,7 +604,7 @@ class TestCourseReIndex(CourseTestCase): Set up the for the course outline tests. """ - super(TestCourseReIndex, self).setUp() + super(TestCourseReIndex, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course.start = datetime.datetime(2014, 1, 1, tzinfo=pytz.utc) modulestore().update_item(self.course, self.user.id) diff --git a/cms/djangoapps/contentstore/views/tests/test_course_updates.py b/cms/djangoapps/contentstore/views/tests/test_course_updates.py index 2b1c055e2b..2a7c1e1dbb 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_updates.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_updates.py @@ -5,8 +5,8 @@ unit tests for course_info views and models. import json -from django.test.utils import override_settings -from mock import patch +from django.test.utils import override_settings # lint-amnesty, pylint: disable=unused-import +from mock import patch # lint-amnesty, pylint: disable=unused-import from opaque_keys.edx.keys import UsageKey from cms.djangoapps.contentstore.tests.test_course_settings import CourseTestCase @@ -15,7 +15,7 @@ from openedx.core.lib.xblock_utils import get_course_update_items from xmodule.modulestore.django import modulestore -class CourseUpdateTest(CourseTestCase): +class CourseUpdateTest(CourseTestCase): # lint-amnesty, pylint: disable=missing-class-docstring def create_update_url(self, provided_id=None, course_key=None): if course_key is None: @@ -45,7 +45,7 @@ class CourseUpdateTest(CourseTestCase): ) self.assertContains(resp, 'Course Updates', status_code=200) - init_content = '' payload = get_response(content, 'January 8, 2013') self.assertHTMLEqual(payload['content'], content) @@ -223,7 +223,7 @@ class CourseUpdateTest(CourseTestCase): course_updates.data = 'bad news' modulestore().update_item(course_updates, self.user.id) - init_content = '' payload = {'content': content, 'date': 'January 8, 2013'} diff --git a/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py b/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py index 95a623c935..58ff6b7639 100644 --- a/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py +++ b/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py @@ -20,7 +20,7 @@ class CreditEligibilityTest(CourseTestCase): eligibility requirements. """ def setUp(self): - super(CreditEligibilityTest, self).setUp() + super(CreditEligibilityTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create(org='edX', number='dummy', display_name='Credit Course') self.course_details_url = reverse_course_url('settings_handler', six.text_type(self.course.id)) diff --git a/cms/djangoapps/contentstore/views/tests/test_entrance_exam.py b/cms/djangoapps/contentstore/views/tests/test_entrance_exam.py index bb80d7fa89..0dcc9acb0a 100644 --- a/cms/djangoapps/contentstore/views/tests/test_entrance_exam.py +++ b/cms/djangoapps/contentstore/views/tests/test_entrance_exam.py @@ -7,7 +7,7 @@ import json 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.test.client import RequestFactory from milestones.tests.utils import MilestonesTestCaseMixin from mock import patch @@ -40,7 +40,7 @@ class EntranceExamHandlerTests(CourseTestCase, MilestonesTestCaseMixin): """ Shared scaffolding for individual test runs """ - super(EntranceExamHandlerTests, self).setUp() + super(EntranceExamHandlerTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_key = self.course.id self.usage_key = self.course.location self.course_url = '/course/{}'.format(six.text_type(self.course.id)) diff --git a/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py b/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py index c24d3fa044..c7a0e5d585 100644 --- a/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py +++ b/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py @@ -32,7 +32,7 @@ class TestExamSettingsView(CourseTestCase, UrlResetMixin): """ Set up the for the exam settings view tests. """ - super(TestExamSettingsView, self).setUp() + super(TestExamSettingsView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.reset_urls() @staticmethod diff --git a/cms/djangoapps/contentstore/views/tests/test_gating.py b/cms/djangoapps/contentstore/views/tests/test_gating.py index 16a95dcf13..e12842e61b 100644 --- a/cms/djangoapps/contentstore/views/tests/test_gating.py +++ b/cms/djangoapps/contentstore/views/tests/test_gating.py @@ -30,7 +30,7 @@ class TestSubsectionGating(CourseTestCase): """ Initial data setup """ - super(TestSubsectionGating, self).setUp() + super(TestSubsectionGating, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Enable subsection gating for the test course self.course.enable_subsection_gating = True diff --git a/cms/djangoapps/contentstore/views/tests/test_group_configurations.py b/cms/djangoapps/contentstore/views/tests/test_group_configurations.py index 9ad6f81caa..c62f237619 100644 --- a/cms/djangoapps/contentstore/views/tests/test_group_configurations.py +++ b/cms/djangoapps/contentstore/views/tests/test_group_configurations.py @@ -267,7 +267,7 @@ class GroupConfigurationsListHandlerTestCase(CourseTestCase, GroupConfigurations # This creates a random UserPartition. self.course.user_partitions = [ - UserPartition(0, 'First name', 'First description', [Group(0, 'Group A'), Group(1, 'Group B'), Group(2, 'Group C')]), + UserPartition(0, 'First name', 'First description', [Group(0, 'Group A'), Group(1, 'Group B'), Group(2, 'Group C')]), # lint-amnesty, pylint: disable=line-too-long ] self.save_course() @@ -873,7 +873,7 @@ class GroupConfigurationsUsageInfoTestCase(CourseTestCase, HelperMethods): ] self.store.update_item(self.course, ModuleStoreEnum.UserID.test) - __, split_test, problem = self._create_content_experiment(cid=0, name_suffix='0', group_id=3, cid_for_problem=1) + __, split_test, problem = self._create_content_experiment(cid=0, name_suffix='0', group_id=3, cid_for_problem=1) # lint-amnesty, pylint: disable=unused-variable expected = { 'id': 1, diff --git a/cms/djangoapps/contentstore/views/tests/test_header_menu.py b/cms/djangoapps/contentstore/views/tests/test_header_menu.py index f2fd6e8c2d..9f38f07429 100644 --- a/cms/djangoapps/contentstore/views/tests/test_header_menu.py +++ b/cms/djangoapps/contentstore/views/tests/test_header_menu.py @@ -31,7 +31,7 @@ class TestHeaderMenu(CourseTestCase, UrlResetMixin): """ Set up the for the course header menu tests. """ - super(TestHeaderMenu, self).setUp() + super(TestHeaderMenu, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.reset_urls() def test_header_menu_without_web_certs_enabled(self): diff --git a/cms/djangoapps/contentstore/views/tests/test_import_export.py b/cms/djangoapps/contentstore/views/tests/test_import_export.py index 0d1d637529..9a4dbd94a3 100644 --- a/cms/djangoapps/contentstore/views/tests/test_import_export.py +++ b/cms/djangoapps/contentstore/views/tests/test_import_export.py @@ -57,7 +57,7 @@ class ImportEntranceExamTestCase(CourseTestCase, MilestonesTestCaseMixin): """ def setUp(self): - super(ImportEntranceExamTestCase, self).setUp() + super(ImportEntranceExamTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse_course_url('import_handler', self.course.id) self.content_dir = path(tempfile.mkdtemp()) self.addCleanup(shutil.rmtree, self.content_dir) @@ -94,7 +94,7 @@ class ImportEntranceExamTestCase(CourseTestCase, MilestonesTestCaseMixin): self.assertIsNotNone(course) self.assertEqual(course.entrance_exam_enabled, False) - with open(self.entrance_exam_tar, 'rb') as gtar: # pylint: disable=open-builtin + with open(self.entrance_exam_tar, 'rb') as gtar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin args = {"name": self.entrance_exam_tar, "course-data": [gtar]} resp = self.client.post(self.url, args) self.assertEqual(resp.status_code, 200) @@ -126,7 +126,7 @@ class ImportEntranceExamTestCase(CourseTestCase, MilestonesTestCaseMixin): self.assertTrue(len(content_milestones)) # Now import entrance exam course - with open(self.entrance_exam_tar, 'rb') as gtar: # pylint: disable=open-builtin + with open(self.entrance_exam_tar, 'rb') as gtar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin args = {"name": self.entrance_exam_tar, "course-data": [gtar]} resp = self.client.post(self.url, args) self.assertEqual(resp.status_code, 200) @@ -145,14 +145,14 @@ class ImportTestCase(CourseTestCase): CREATE_USER = True def setUp(self): - super(ImportTestCase, self).setUp() + super(ImportTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse_course_url('import_handler', self.course.id) self.content_dir = path(tempfile.mkdtemp()) self.addCleanup(shutil.rmtree, self.content_dir) def touch(name): """ Equivalent to shell's 'touch'""" - with open(name, 'a'): # pylint: disable=W6005 + with open(name, 'a'): os.utime(name, None) # Create tar test files ----------------------------------------------- @@ -185,7 +185,7 @@ class ImportTestCase(CourseTestCase): Check that the response for a tar.gz import without a course.xml is correct. """ - with open(self.bad_tar, 'rb') as btar: # pylint: disable=open-builtin + with open(self.bad_tar, 'rb') as btar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin resp = self.client.post( self.url, { @@ -210,7 +210,7 @@ class ImportTestCase(CourseTestCase): Check that the response for a tar.gz import with a course.xml is correct. """ - with open(self.good_tar, 'rb') as gtar: # pylint: disable=open-builtin + with open(self.good_tar, 'rb') as gtar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin args = {"name": self.good_tar, "course-data": [gtar]} resp = self.client.post(self.url, args) @@ -229,7 +229,7 @@ class ImportTestCase(CourseTestCase): display_name_before_import = course.display_name # Check that global staff user can import course - with open(self.good_tar, 'rb') as gtar: # pylint: disable=open-builtin + with open(self.good_tar, 'rb') as gtar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin args = {"name": self.good_tar, "course-data": [gtar]} resp = self.client.post(self.url, args) self.assertEqual(resp.status_code, 200) @@ -247,7 +247,7 @@ class ImportTestCase(CourseTestCase): # Now course staff user can also successfully import course self.client.login(username=nonstaff_user.username, password='foo') - with open(self.good_tar, 'rb') as gtar: # pylint: disable=open-builtin + with open(self.good_tar, 'rb') as gtar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin args = {"name": self.good_tar, "course-data": [gtar]} resp = self.client.post(self.url, args) self.assertEqual(resp.status_code, 200) @@ -341,7 +341,7 @@ class ImportTestCase(CourseTestCase): def try_tar(tarpath): """ Attempt to tar an unacceptable file """ - with open(tarpath, 'rb') as tar: # pylint: disable=open-builtin + with open(tarpath, 'rb') as tar: # lint-amnesty, pylint: disable=bad-option-value, open-builtin args = {"name": tarpath, "course-data": [tar]} resp = self.client.post(self.url, args) self.assertEqual(resp.status_code, 200) @@ -501,7 +501,7 @@ class ImportTestCase(CourseTestCase): # Construct the modulestore for storing the import (using the previously created contentstore) with SPLIT_MODULESTORE_SETUP.build(contentstore=source_content) as source_store: # Use the test branch setting. - with source_store.branch_setting(branch_setting): + with source_store.branch_setting(branch_setting): # lint-amnesty, pylint: disable=no-member source_library_key = LibraryLocator(org='TestOrg', library='TestProbs') extract_dir = path(tempfile.mkdtemp(dir=settings.DATA_DIR)) @@ -538,7 +538,7 @@ class ExportTestCase(CourseTestCase): """ Sets up the test course. """ - super(ExportTestCase, self).setUp() + super(ExportTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse_course_url('export_handler', self.course.id) self.status_url = reverse_course_url('export_status_handler', self.course.id) @@ -854,7 +854,7 @@ class TestLibraryImportExport(CourseTestCase): """ def setUp(self): - super(TestLibraryImportExport, self).setUp() + super(TestLibraryImportExport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.export_dir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, self.export_dir, ignore_errors=True) @@ -912,7 +912,7 @@ class TestCourseExportImport(LibraryTestCase): """ def setUp(self): - super(TestCourseExportImport, self).setUp() + super(TestCourseExportImport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.export_dir = tempfile.mkdtemp() # Create a problem in library @@ -1035,7 +1035,7 @@ class TestCourseExportImportProblem(CourseTestCase): """ def setUp(self): - super(TestCourseExportImportProblem, self).setUp() + super(TestCourseExportImportProblem, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.export_dir = tempfile.mkdtemp() self.source_course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split) self.addCleanup(shutil.rmtree, self.export_dir, ignore_errors=True) diff --git a/cms/djangoapps/contentstore/views/tests/test_item.py b/cms/djangoapps/contentstore/views/tests/test_item.py index 38a6318206..2124f572e3 100644 --- a/cms/djangoapps/contentstore/views/tests/test_item.py +++ b/cms/djangoapps/contentstore/views/tests/test_item.py @@ -89,7 +89,7 @@ class AsideTest(XBlockAside): class ItemTest(CourseTestCase): """ Base test class for create, save, and delete """ def setUp(self): - super(ItemTest, self).setUp() + super(ItemTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_key = self.course.id self.usage_key = self.course.location @@ -115,7 +115,7 @@ class ItemTest(CourseTestCase): key = key.map_into_course(CourseKey.from_string(parsed['courseKey'])) return key - def create_xblock(self, parent_usage_key=None, display_name=None, category=None, boilerplate=None): + def create_xblock(self, parent_usage_key=None, display_name=None, category=None, boilerplate=None): # lint-amnesty, pylint: disable=missing-function-docstring data = { 'parent_locator': six.text_type( self.usage_key @@ -680,7 +680,7 @@ class TestDuplicateItem(ItemTest, DuplicateHelper): def setUp(self): """ Creates the test course structure and a few components to 'duplicate'. """ - super(TestDuplicateItem, self).setUp() + super(TestDuplicateItem, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Create a parent chapter (for testing children of children). resp = self.create_xblock(parent_usage_key=self.usage_key, category='chapter') self.chapter_usage_key = self.response_usage_key(resp) @@ -789,7 +789,7 @@ class TestMoveItem(ItemTest): """ Creates the test course structure to build course outline tree. """ - super(TestMoveItem, self).setUp() + super(TestMoveItem, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.setup_course() def setup_course(self, default_store=None): @@ -1208,7 +1208,7 @@ class TestMoveItem(ItemTest): self.course, course_id=self.course.id, ) - html.runtime._services['partitions'] = partitions_service + html.runtime._services['partitions'] = partitions_service # lint-amnesty, pylint: disable=protected-access # Set access settings so html will contradict vert2 when moved into that unit vert2.group_access = {self.course.user_partitions[0].id: [group1.id]} @@ -1341,7 +1341,7 @@ class TestDuplicateItemWithAsides(ItemTest, DuplicateHelper): def setUp(self): """ Creates the test course structure and a few components to 'duplicate'. """ - super(TestDuplicateItemWithAsides, self).setUp() + super(TestDuplicateItemWithAsides, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Create a parent chapter resp = self.create_xblock(parent_usage_key=self.usage_key, category='chapter') self.chapter_usage_key = self.response_usage_key(resp) @@ -1402,7 +1402,7 @@ class TestEditItemSetup(ItemTest): def setUp(self): """ Creates the test course structure and a couple problems to 'edit'. """ - super(TestEditItemSetup, self).setUp() + super(TestEditItemSetup, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # create a chapter display_name = 'chapter created' resp = self.create_xblock(display_name=display_name, category='chapter') @@ -1768,7 +1768,7 @@ class TestEditItem(TestEditItemSetup): data={'publish': 'make_public'} ) self._verify_published_with_no_draft(self.problem_usage_key) - published = modulestore().get_item(self.problem_usage_key, revision=ModuleStoreEnum.RevisionOption.published_only) + published = modulestore().get_item(self.problem_usage_key, revision=ModuleStoreEnum.RevisionOption.published_only) # lint-amnesty, pylint: disable=line-too-long # Update the draft version and check that published is different. self.client.ajax_post( @@ -1924,7 +1924,7 @@ class TestEditSplitModule(ItemTest): """ def setUp(self): - super(TestEditSplitModule, self).setUp() + super(TestEditSplitModule, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() self.first_user_partition_group_1 = Group(six.text_type(MINIMUM_STATIC_PARTITION_ID + 1), 'alpha') @@ -2147,7 +2147,7 @@ class TestComponentHandler(TestCase): """Tests for component handler api""" def setUp(self): - super(TestComponentHandler, self).setUp() + super(TestComponentHandler, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.request_factory = RequestFactory() @@ -2179,7 +2179,7 @@ class TestComponentHandler(TestCase): @ddt.data('GET', 'POST', 'PUT', 'DELETE') def test_request_method(self, method): - def check_handler(handler, request, suffix): + def check_handler(handler, request, suffix): # lint-amnesty, pylint: disable=unused-argument self.assertEqual(request.method, method) return Response() @@ -2194,7 +2194,7 @@ class TestComponentHandler(TestCase): @ddt.data(200, 404, 500) def test_response_code(self, status_code): - def create_response(handler, request, suffix): + def create_response(handler, request, suffix): # lint-amnesty, pylint: disable=unused-argument return Response(status_code=status_code) self.descriptor.handle = create_response @@ -2208,7 +2208,7 @@ class TestComponentHandler(TestCase): """ test get_aside_from_xblock called """ - def create_response(handler, request, suffix): + def create_response(handler, request, suffix): # lint-amnesty, pylint: disable=unused-argument """create dummy response""" return Response(status_code=200) @@ -2246,7 +2246,7 @@ class TestComponentTemplates(CourseTestCase): """ def setUp(self): - super(TestComponentTemplates, self).setUp() + super(TestComponentTemplates, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Advanced Module support levels. XBlockStudioConfiguration.objects.create(name='poll', enabled=True, support_level="fs") XBlockStudioConfiguration.objects.create(name='survey', enabled=True, support_level="ps") @@ -2508,7 +2508,7 @@ class TestXBlockInfo(ItemTest): Unit tests for XBlock's outline handling. """ def setUp(self): - super(TestXBlockInfo, self).setUp() + super(TestXBlockInfo, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments user_id = self.user.id self.chapter = ItemFactory.create( parent_location=self.course.location, category='chapter', display_name="Week 1", user_id=user_id, @@ -2953,7 +2953,7 @@ class TestLibraryXBlockInfo(ModuleStoreTestCase): """ def setUp(self): - super(TestLibraryXBlockInfo, self).setUp() + super(TestLibraryXBlockInfo, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments user_id = self.user.id self.library = LibraryFactory.create() self.top_level_html = ItemFactory.create( diff --git a/cms/djangoapps/contentstore/views/tests/test_library.py b/cms/djangoapps/contentstore/views/tests/test_library.py index c7ea9cbfdb..2cd1e53fde 100644 --- a/cms/djangoapps/contentstore/views/tests/test_library.py +++ b/cms/djangoapps/contentstore/views/tests/test_library.py @@ -44,7 +44,7 @@ class UnitTestLibraries(CourseTestCase): """ def setUp(self): - super(UnitTestLibraries, self).setUp() + super(UnitTestLibraries, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.client = AjaxEnabledTestClient() self.client.login(username=self.user.username, password=self.user_password) diff --git a/cms/djangoapps/contentstore/views/tests/test_organizations.py b/cms/djangoapps/contentstore/views/tests/test_organizations.py index ce12b9899f..b48252ec61 100644 --- a/cms/djangoapps/contentstore/views/tests/test_organizations.py +++ b/cms/djangoapps/contentstore/views/tests/test_organizations.py @@ -13,7 +13,7 @@ from common.djangoapps.student.tests.factories import UserFactory class TestOrganizationListing(TestCase): """Verify Organization listing behavior.""" def setUp(self): - super(TestOrganizationListing, self).setUp() + super(TestOrganizationListing, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.staff = UserFactory(is_staff=True) self.client.login(username=self.staff.username, password='test') self.org_names_listing_url = reverse('organizations') diff --git a/cms/djangoapps/contentstore/views/tests/test_preview.py b/cms/djangoapps/contentstore/views/tests/test_preview.py index 86fd30e1c6..054e9bd2fa 100644 --- a/cms/djangoapps/contentstore/views/tests/test_preview.py +++ b/cms/djangoapps/contentstore/views/tests/test_preview.py @@ -174,7 +174,7 @@ class PureXBlock(XBlock): """ Pure XBlock to use in tests. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass @ddt.ddt @@ -186,7 +186,7 @@ class StudioXBlockServiceBindingTest(ModuleStoreTestCase): """ Set up the user and request that will be used. """ - super(StudioXBlockServiceBindingTest, self).setUp() + super(StudioXBlockServiceBindingTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() self.course = CourseFactory.create() self.request = mock.Mock() diff --git a/cms/djangoapps/contentstore/views/tests/test_tabs.py b/cms/djangoapps/contentstore/views/tests/test_tabs.py index b4b3c02918..0d3a470c04 100644 --- a/cms/djangoapps/contentstore/views/tests/test_tabs.py +++ b/cms/djangoapps/contentstore/views/tests/test_tabs.py @@ -20,7 +20,7 @@ class TabsPageTests(CourseTestCase): """Common setup for tests""" # call super class to setup course, etc. - super(TabsPageTests, self).setUp() + super(TabsPageTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Set the URL for tests self.url = reverse_course_url('tabs_handler', self.course.id) diff --git a/cms/djangoapps/contentstore/views/tests/test_textbooks.py b/cms/djangoapps/contentstore/views/tests/test_textbooks.py index e7122f128f..ed42db2c94 100644 --- a/cms/djangoapps/contentstore/views/tests/test_textbooks.py +++ b/cms/djangoapps/contentstore/views/tests/test_textbooks.py @@ -14,7 +14,7 @@ class TextbookIndexTestCase(CourseTestCase): "Test cases for the textbook index page" def setUp(self): "Set the URL for tests" - super(TextbookIndexTestCase, self).setUp() + super(TextbookIndexTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse_course_url('textbooks_list_handler', self.course.id) def test_view_index(self): @@ -113,7 +113,7 @@ class TextbookCreateTestCase(CourseTestCase): def setUp(self): "Set up a url and some textbook content for tests" - super(TextbookCreateTestCase, self).setUp() + super(TextbookCreateTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse_course_url('textbooks_list_handler', self.course.id) self.textbook = { @@ -173,7 +173,7 @@ class TextbookDetailTestCase(CourseTestCase): def setUp(self): "Set some useful content and URLs for tests" - super(TextbookDetailTestCase, self).setUp() + super(TextbookDetailTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.textbook1 = { "tab_title": "Economics", "id": 1, @@ -295,7 +295,7 @@ class TextbookValidationTestCase(TestCase): def setUp(self): "Set some useful content for tests" - super(TextbookValidationTestCase, self).setUp() + super(TextbookValidationTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.tb1 = { "tab_title": "Hi, mom!", diff --git a/cms/djangoapps/contentstore/views/tests/test_transcript_settings.py b/cms/djangoapps/contentstore/views/tests/test_transcript_settings.py index 90ce580450..3d6b3ed876 100644 --- a/cms/djangoapps/contentstore/views/tests/test_transcript_settings.py +++ b/cms/djangoapps/contentstore/views/tests/test_transcript_settings.py @@ -1,8 +1,8 @@ -# -*- coding: utf-8 -*- +# lint-amnesty, pylint: disable=missing-module-docstring import json -from io import BytesIO +from io import BytesIO # lint-amnesty, pylint: disable=unused-import import ddt import six diff --git a/cms/djangoapps/contentstore/views/tests/test_transcripts.py b/cms/djangoapps/contentstore/views/tests/test_transcripts.py index 263b513c42..ada70cf196 100644 --- a/cms/djangoapps/contentstore/views/tests/test_transcripts.py +++ b/cms/djangoapps/contentstore/views/tests/test_transcripts.py @@ -82,7 +82,7 @@ class BaseTranscripts(CourseTestCase): def setUp(self): """Create initial data.""" - super(BaseTranscripts, self).setUp() + super(BaseTranscripts, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Add video module data = { @@ -156,7 +156,7 @@ class TestUploadTranscripts(BaseTranscripts): Tests for '/transcripts/upload' endpoint. """ def setUp(self): - super(TestUploadTranscripts, self).setUp() + super(TestUploadTranscripts, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.contents = { 'good': SRT_TRANSCRIPT_CONTENT, 'bad': u'Some BAD data', @@ -388,7 +388,7 @@ class TestChooseTranscripts(BaseTranscripts): Tests for '/transcripts/choose' endpoint. """ def setUp(self): - super(TestChooseTranscripts, self).setUp() + super(TestChooseTranscripts, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Create test transcript in contentstore self.chosen_html5_id = 'test_html5_subs' @@ -507,7 +507,7 @@ class TestRenameTranscripts(BaseTranscripts): Tests for '/transcripts/rename' endpoint. """ def setUp(self): - super(TestRenameTranscripts, self).setUp() + super(TestRenameTranscripts, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Create test transcript in contentstore and update item's sub. self.item.sub = 'test_video_subs' @@ -633,7 +633,7 @@ class TestReplaceTranscripts(BaseTranscripts): Tests for '/transcripts/replace' endpoint. """ def setUp(self): - super(TestReplaceTranscripts, self).setUp() + super(TestReplaceTranscripts, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.youtube_id = 'test_yt_id' # Setup a VEDA produced video and persist `edx_video_id` in VAL. diff --git a/cms/djangoapps/contentstore/views/tests/test_unit_page.py b/cms/djangoapps/contentstore/views/tests/test_unit_page.py index 02851c1c13..78a36cb12d 100644 --- a/cms/djangoapps/contentstore/views/tests/test_unit_page.py +++ b/cms/djangoapps/contentstore/views/tests/test_unit_page.py @@ -16,7 +16,7 @@ class UnitPageTestCase(StudioPageTestCase): """ def setUp(self): - super(UnitPageTestCase, self).setUp() + super(UnitPageTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.vertical = ItemFactory.create(parent_location=self.sequential.location, category='vertical', display_name='Unit') self.video = ItemFactory.create(parent_location=self.vertical.location, @@ -27,7 +27,7 @@ class UnitPageTestCase(StudioPageTestCase): """ Verify that a public xblock's preview returns the expected HTML. """ - published_video = self.store.publish(self.video.location, self.user.id) + published_video = self.store.publish(self.video.location, self.user.id) # lint-amnesty, pylint: disable=unused-variable self.validate_preview_html(self.video, STUDENT_VIEW, can_add=False) def test_draft_component_preview_html(self): diff --git a/cms/djangoapps/contentstore/views/tests/test_user.py b/cms/djangoapps/contentstore/views/tests/test_user.py index c0ccf75122..9f30d18a8d 100644 --- a/cms/djangoapps/contentstore/views/tests/test_user.py +++ b/cms/djangoapps/contentstore/views/tests/test_user.py @@ -5,7 +5,7 @@ Tests for contentstore/views/user.py. import json -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from cms.djangoapps.contentstore.tests.utils import CourseTestCase from cms.djangoapps.contentstore.utils import reverse_course_url @@ -14,9 +14,9 @@ from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.student.roles import CourseInstructorRole, CourseStaffRole -class UsersTestCase(CourseTestCase): +class UsersTestCase(CourseTestCase): # lint-amnesty, pylint: disable=missing-class-docstring def setUp(self): - super(UsersTestCase, self).setUp() + super(UsersTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.ext_user = User.objects.create_user( "joe", "joe@comedycentral.com", "haha") self.ext_user.is_active = True diff --git a/cms/djangoapps/contentstore/views/tests/test_videos.py b/cms/djangoapps/contentstore/views/tests/test_videos.py index b3148b0451..8b5d1c44ad 100644 --- a/cms/djangoapps/contentstore/views/tests/test_videos.py +++ b/cms/djangoapps/contentstore/views/tests/test_videos.py @@ -64,16 +64,16 @@ class VideoUploadTestBase(object): def get_url_for_course_key(self, course_key, kwargs=None): """Return video handler URL for the given course""" - return reverse_course_url(self.VIEW_NAME, course_key, kwargs) + return reverse_course_url(self.VIEW_NAME, course_key, kwargs) # lint-amnesty, pylint: disable=no-member def setUp(self): - super(VideoUploadTestBase, self).setUp() + super(VideoUploadTestBase, self).setUp() # lint-amnesty, pylint: disable=no-member, super-with-arguments self.url = self.get_url_for_course_key(self.course.id) self.test_token = "test_token" self.course.video_upload_pipeline = { "course_video_upload_token": self.test_token, } - self.save_course() + self.save_course() # lint-amnesty, pylint: disable=no-member # create another course for videos belonging to multiple courses self.course2 = CourseFactory.create() @@ -81,7 +81,7 @@ class VideoUploadTestBase(object): "course_video_upload_token": self.test_token, } self.course2.save() - self.store.update_item(self.course2, self.user.id) + self.store.update_item(self.course2, self.user.id) # lint-amnesty, pylint: disable=no-member # course ids for videos course_ids = [six.text_type(self.course.id), six.text_type(self.course2.id)] @@ -1046,7 +1046,7 @@ class VideoImageTestCase(VideoUploadTestBase, CourseTestCase): 'width': 16, # 16x9 'height': 9 }, - u'Recommended image resolution is {image_file_max_width}x{image_file_max_height}. The minimum resolution is {image_file_min_width}x{image_file_min_height}.'.format( + u'Recommended image resolution is {image_file_max_width}x{image_file_max_height}. The minimum resolution is {image_file_min_width}x{image_file_min_height}.'.format( # lint-amnesty, pylint: disable=line-too-long image_file_max_width=settings.VIDEO_IMAGE_MAX_WIDTH, image_file_max_height=settings.VIDEO_IMAGE_MAX_HEIGHT, image_file_min_width=settings.VIDEO_IMAGE_MIN_WIDTH, @@ -1058,7 +1058,7 @@ class VideoImageTestCase(VideoUploadTestBase, CourseTestCase): 'width': settings.VIDEO_IMAGE_MIN_WIDTH - 10, 'height': settings.VIDEO_IMAGE_MIN_HEIGHT }, - u'Recommended image resolution is {image_file_max_width}x{image_file_max_height}. The minimum resolution is {image_file_min_width}x{image_file_min_height}.'.format( + u'Recommended image resolution is {image_file_max_width}x{image_file_max_height}. The minimum resolution is {image_file_min_width}x{image_file_min_height}.'.format( # lint-amnesty, pylint: disable=line-too-long image_file_max_width=settings.VIDEO_IMAGE_MAX_WIDTH, image_file_max_height=settings.VIDEO_IMAGE_MAX_HEIGHT, image_file_min_width=settings.VIDEO_IMAGE_MIN_WIDTH, @@ -1487,7 +1487,7 @@ class VideoUrlsCsvTestCase(VideoUploadTestMixin, CourseTestCase): VIEW_NAME = "video_encodings_download" def setUp(self): - super(VideoUrlsCsvTestCase, self).setUp() + super(VideoUrlsCsvTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments VideoUploadConfig(profile_whitelist="profile1").save() def _check_csv_response(self, expected_profiles): diff --git a/cms/djangoapps/contentstore/views/tests/utils.py b/cms/djangoapps/contentstore/views/tests/utils.py index c2bb78d538..9d53bf5cd5 100644 --- a/cms/djangoapps/contentstore/views/tests/utils.py +++ b/cms/djangoapps/contentstore/views/tests/utils.py @@ -17,7 +17,7 @@ class StudioPageTestCase(CourseTestCase): """ def setUp(self): - super(StudioPageTestCase, self).setUp() + super(StudioPageTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.chapter = ItemFactory.create(parent_location=self.course.location, category='chapter', display_name="Week 1") self.sequential = ItemFactory.create(parent_location=self.chapter.location, diff --git a/cms/djangoapps/contentstore/views/transcript_settings.py b/cms/djangoapps/contentstore/views/transcript_settings.py index f92722160b..f86ae7ed9e 100644 --- a/cms/djangoapps/contentstore/views/transcript_settings.py +++ b/cms/djangoapps/contentstore/views/transcript_settings.py @@ -193,7 +193,7 @@ def validate_transcript_upload_data(data, files): data['language_code'] != data['new_language_code'] and data['new_language_code'] in get_available_transcript_languages(video_id=data['edx_video_id']) ): - error = _(u'A transcript with the "{language_code}" language code already exists.'.format( + error = _(u'A transcript with the "{language_code}" language code already exists.'.format( # lint-amnesty, pylint: disable=translation-of-non-string language_code=data['new_language_code'] )) elif 'file' not in files: diff --git a/cms/djangoapps/contentstore/views/transcripts_ajax.py b/cms/djangoapps/contentstore/views/transcripts_ajax.py index 461fd9deb2..f66a5247c4 100644 --- a/cms/djangoapps/contentstore/views/transcripts_ajax.py +++ b/cms/djangoapps/contentstore/views/transcripts_ajax.py @@ -260,7 +260,7 @@ def download_transcripts(request): try: content, filename, mimetype = get_transcript(video, lang=u'en') except NotFoundError: - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from # Construct an HTTP response response = HttpResponse(content, content_type=mimetype) @@ -269,7 +269,7 @@ def download_transcripts(request): @login_required -def check_transcripts(request): +def check_transcripts(request): # lint-amnesty, pylint: disable=too-many-statements """ Check state of transcripts availability. @@ -463,7 +463,7 @@ def _validate_transcripts_data(request): try: item = _get_item(request, data) except (InvalidKeyError, ItemNotFoundError): - raise TranscriptsRequestValidationException(_("Can't find item by locator.")) + raise TranscriptsRequestValidationException(_("Can't find item by locator.")) # lint-amnesty, pylint: disable=raise-missing-from if item.category != 'video': raise TranscriptsRequestValidationException(_('Transcripts are supported only for "video" modules.')) diff --git a/cms/djangoapps/contentstore/views/user.py b/cms/djangoapps/contentstore/views/user.py index 3af7087d24..cc8acf5bb5 100644 --- a/cms/djangoapps/contentstore/views/user.py +++ b/cms/djangoapps/contentstore/views/user.py @@ -2,7 +2,7 @@ from django.contrib.auth.decorators import login_required -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.http import HttpResponseNotFound from django.utils.translation import ugettext as _ diff --git a/cms/djangoapps/contentstore/views/videos.py b/cms/djangoapps/contentstore/views/videos.py index c17d3826df..03150f7697 100644 --- a/cms/djangoapps/contentstore/views/videos.py +++ b/cms/djangoapps/contentstore/views/videos.py @@ -14,7 +14,7 @@ from uuid import uuid4 import six from boto import s3 -from boto.sts import STSConnection +from boto.sts import STSConnection # lint-amnesty, pylint: disable=unused-import from django.conf import settings from django.contrib.auth.decorators import login_required from django.contrib.staticfiles.storage import staticfiles_storage diff --git a/common/lib/symmath/symmath/__init__.py b/common/lib/symmath/symmath/__init__.py index a4233e4dde..f492a56f65 100644 --- a/common/lib/symmath/symmath/__init__.py +++ b/common/lib/symmath/symmath/__init__.py @@ -1,2 +1,3 @@ +# lint-amnesty, pylint: disable=django-not-configured, missing-module-docstring from .formula import * from .symmath_check import * diff --git a/common/lib/symmath/symmath/formula.py b/common/lib/symmath/symmath/formula.py index edc4ad580a..d72389b72c 100644 --- a/common/lib/symmath/symmath/formula.py +++ b/common/lib/symmath/symmath/formula.py @@ -21,7 +21,7 @@ import unicodedata #import subprocess from copy import deepcopy from functools import reduce -from xml.sax.saxutils import unescape +from xml.sax.saxutils import unescape # lint-amnesty, pylint: disable=unused-import import six import sympy @@ -210,7 +210,7 @@ class formula(object): for k in xml: tag = gettag(k) - if tag == 'mi' or tag == 'ci': + if tag == 'mi' or tag == 'ci': # lint-amnesty, pylint: disable=consider-using-in usym = six.text_type(k.text) try: udata = unicodedata.name(usym) @@ -227,7 +227,7 @@ class formula(object): self.fix_greek_in_mathml(k) return xml - def preprocess_pmathml(self, xml): + def preprocess_pmathml(self, xml): # lint-amnesty, pylint: disable=too-many-statements r""" Pre-process presentation MathML from ASCIIMathML to make it more acceptable for SnuggleTeX, and also to accomodate some sympy @@ -420,7 +420,7 @@ class formula(object): self.xml = xml # pylint: disable=attribute-defined-outside-init return self.xml - def get_content_mathml(self): + def get_content_mathml(self): # lint-amnesty, pylint: disable=missing-function-docstring if self.the_cmathml: return self.the_cmathml @@ -436,7 +436,7 @@ class formula(object): cmathml = property(get_content_mathml, None, None, 'content MathML representation') - def make_sympy(self, xml=None): + def make_sympy(self, xml=None): # lint-amnesty, pylint: disable=too-many-statements """ Return sympy expression for the math formula. The math formula is converted to Content MathML then that is parsed. @@ -457,11 +457,11 @@ class formula(object): cmml = self.cmathml xml = etree.fromstring(str(cmml)) except Exception as err: - if 'conversion from Presentation MathML to Content MathML was not successful' in cmml: + if 'conversion from Presentation MathML to Content MathML was not successful' in cmml: # lint-amnesty, pylint: disable=unsupported-membership-test msg = "Illegal math expression" else: msg = 'Err %s while converting cmathml to xml; cmml=%s' % (err, cmml) - raise Exception(msg) + raise Exception(msg) # lint-amnesty, pylint: disable=raise-missing-from xml = self.fix_greek_in_mathml(xml) self.the_sympy = self.make_sympy(xml[0]) else: @@ -482,14 +482,14 @@ class formula(object): def op_minus(*args): if len(args) == 1: return -args[0] - if not len(args) == 2: + if not len(args) == 2: # lint-amnesty, pylint: disable=unneeded-not raise Exception('minus given wrong number of arguments!') #return sympy.Add(args[0],-args[1]) return args[0] - args[1] opdict = { 'plus': op_plus, - 'divide': operator.div, + 'divide': operator.div, # lint-amnesty, pylint: disable=no-member 'times': op_times, 'minus': op_minus, 'root': sympy.sqrt, @@ -546,7 +546,7 @@ class formula(object): except Exception as err: self.args = args # pylint: disable=attribute-defined-outside-init self.op = op # pylint: disable=attribute-defined-outside-init, invalid-name - raise Exception('[formula] error=%s failed to apply %s to args=%s' % (err, opstr, args)) + raise Exception('[formula] error=%s failed to apply %s to args=%s' % (err, opstr, args)) # lint-amnesty, pylint: disable=raise-missing-from return res else: raise Exception('[formula]: unknown operator tag %s' % (opstr)) diff --git a/common/lib/symmath/symmath/symmath_check.py b/common/lib/symmath/symmath/symmath_check.py index 5a1a2171a7..6ac03a47d2 100644 --- a/common/lib/symmath/symmath/symmath_check.py +++ b/common/lib/symmath/symmath/symmath_check.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python # lint-amnesty, pylint: disable=missing-module-docstring # -*- coding: utf-8 -*- # # File: symmath_check.py @@ -16,7 +16,7 @@ from markupsafe import escape from openedx.core.djangolib.markup import HTML -from .formula import * +from .formula import * # lint-amnesty, pylint: disable=wildcard-import log = logging.getLogger(__name__) @@ -26,7 +26,7 @@ log = logging.getLogger(__name__) # This is one of the main entry points to call. -def symmath_check_simple(expect, ans, adict={}, symtab=None, extra_options=None): +def symmath_check_simple(expect, ans, adict={}, symtab=None, extra_options=None): # lint-amnesty, pylint: disable=dangerous-default-value, unused-argument """ Check a symbolic mathematical expression using sympy. The input is an ascii string (not MathML) converted to math using sympy.sympify. @@ -51,7 +51,7 @@ def symmath_check_simple(expect, ans, adict={}, symtab=None, extra_options=None) abcsym=options['__ABC__'], symtab=symtab, ) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except return {'ok': False, 'msg': HTML('Error {err}
Failed in evaluating check({expect},{ans})').format( err=err, expect=expect, ans=ans @@ -62,7 +62,7 @@ def symmath_check_simple(expect, ans, adict={}, symtab=None, extra_options=None) # pretty generic checking function -def check(expect, given, numerical=False, matrix=False, normphase=False, abcsym=False, do_qubit=True, symtab=None, dosimplify=False): +def check(expect, given, numerical=False, matrix=False, normphase=False, abcsym=False, do_qubit=True, symtab=None, dosimplify=False): # lint-amnesty, pylint: disable=line-too-long """ Returns dict with @@ -93,19 +93,19 @@ def check(expect, given, numerical=False, matrix=False, normphase=False, abcsym= threshold = float(st) numerical = True - if str(given) == '' and not str(expect) == '': + if str(given) == '' and not str(expect) == '': # lint-amnesty, pylint: disable=unneeded-not return {'ok': False, 'msg': ''} try: xgiven = my_sympify(given, normphase, matrix, do_qubit=do_qubit, abcsym=abcsym, symtab=symtab) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except return {'ok': False, 'msg': HTML('Error {err}
in evaluating your expression "{given}"').format( err=err, given=given )} try: xexpect = my_sympify(expect, normphase, matrix, do_qubit=do_qubit, abcsym=abcsym, symtab=symtab) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except return {'ok': False, 'msg': HTML('Error {err}
in evaluating OUR expression "{expect}"').format( err=err, expect=expect )} @@ -113,12 +113,12 @@ def check(expect, given, numerical=False, matrix=False, normphase=False, abcsym= if 'autonorm' in flags: # normalize trace of matrices try: xgiven /= xgiven.trace() - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except return {'ok': False, 'msg': HTML('Error {err}
in normalizing trace of your expression {xgiven}'). format(err=err, xgiven=to_latex(xgiven))} try: xexpect /= xexpect.trace() - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except return {'ok': False, 'msg': HTML('Error {err}
in normalizing trace of OUR expression {xexpect}'). format(err=err, xexpect=to_latex(xexpect))} @@ -172,7 +172,7 @@ def is_within_tolerance(expected, actual, tolerance): # This is one of the main entry points to call. -def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None): +def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None): # lint-amnesty, pylint: disable=too-many-statements """ Check a symbolic mathematical expression using sympy. The input may be presentation MathML. Uses formula. @@ -220,7 +220,7 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None # parse expected answer try: fexpect = my_sympify(str(expect), matrix=do_matrix, do_qubit=do_qubit) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except msg += HTML('

Error {err} in parsing OUR expected answer "{expect}"

').format(err=err, expect=expect) return {'ok': False, 'msg': make_error_message(msg)} @@ -228,7 +228,7 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None # if expected answer is a number, try parsing provided answer as a number also try: fans = my_sympify(str(ans), matrix=do_matrix, do_qubit=do_qubit) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except fans = None # do a numerical comparison if both expected and answer are numbers @@ -256,7 +256,7 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None # convert mathml answer to formula try: mmlans = dynamath[0] if dynamath else None - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except mmlans = None if not mmlans: return {'ok': False, 'msg': '[symmath_check] failed to get MathML for input; dynamath=%s' % dynamath} @@ -268,7 +268,7 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None try: fsym = f.sympy msg += HTML('

You entered: {sympy}

').format(sympy=to_latex(f.sympy)) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except log.exception("Error evaluating expression '%s' as a valid equation", ans) msg += HTML("

Error in evaluating your expression '{ans}' as a valid equation

").format(ans=ans) if "Illegal math" in str(err): @@ -309,7 +309,7 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None except sympy.ShapeError: msg += HTML("

Error - your input vector or matrix has the wrong dimensions") return {'ok': False, 'msg': make_error_message(msg)} - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except msg += HTML("

Error %s in comparing expected (a list) and your answer

").format(escape(str(err))) if DEBUG: msg += HTML("

{format_exc}
").format(format_exc=traceback.format_exc()) @@ -320,7 +320,7 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None #fexpect = fexpect.simplify() try: diff = (fexpect - fsym) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except diff = None if DEBUG: diff --git a/common/lib/symmath/symmath/test_formula.py b/common/lib/symmath/symmath/test_formula.py index 3895157fd8..25d163f059 100644 --- a/common/lib/symmath/symmath/test_formula.py +++ b/common/lib/symmath/symmath/test_formula.py @@ -16,13 +16,13 @@ def stripXML(xml): return xml -class FormulaTest(unittest.TestCase): +class FormulaTest(unittest.TestCase): # lint-amnesty, pylint: disable=missing-class-docstring # for readability later mathml_start = '' mathml_end = '' def setUp(self): - super(FormulaTest, self).setUp() + super(FormulaTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.formulaInstance = formula('') def test_replace_mathvariants(self): diff --git a/common/lib/symmath/symmath/test_symmath_check.py b/common/lib/symmath/symmath/test_symmath_check.py index 0e2f1c7cc0..0271f42ecc 100644 --- a/common/lib/symmath/symmath/test_symmath_check.py +++ b/common/lib/symmath/symmath/test_symmath_check.py @@ -1,4 +1,4 @@ - +# lint-amnesty, pylint: disable=missing-module-docstring from unittest import TestCase from six.moves import range @@ -6,9 +6,9 @@ from six.moves import range from .symmath_check import symmath_check -class SymmathCheckTest(TestCase): +class SymmathCheckTest(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring def test_symmath_check_integers(self): - number_list = [i for i in range(-100, 100)] + number_list = [i for i in range(-100, 100)] # lint-amnesty, pylint: disable=unnecessary-comprehension self._symmath_check_numbers(number_list) def test_symmath_check_floats(self): @@ -73,7 +73,7 @@ class SymmathCheckTest(TestCase): self.assertTrue('ok' in result and not result['ok']) self.assertNotIn('fail', result['msg']) - def _symmath_check_numbers(self, number_list): + def _symmath_check_numbers(self, number_list): # lint-amnesty, pylint: disable=missing-function-docstring for n in number_list: diff --git a/common/lib/xmodule/xmodule/graders.py b/common/lib/xmodule/xmodule/graders.py index 3ce3dfa329..ecab922afb 100644 --- a/common/lib/xmodule/xmodule/graders.py +++ b/common/lib/xmodule/xmodule/graders.py @@ -333,7 +333,7 @@ class AssignmentFormatGrader(CourseGrader): min_count = 2 would produce the labels "Assignment 3", "Assignment 4" """ - def __init__( + def __init__( # lint-amnesty, pylint: disable=super-init-not-called self, type, # pylint: disable=redefined-builtin min_count, diff --git a/lms/djangoapps/courseware/masquerade.py b/lms/djangoapps/courseware/masquerade.py index 521098a8fe..bfb35f671c 100644 --- a/lms/djangoapps/courseware/masquerade.py +++ b/lms/djangoapps/courseware/masquerade.py @@ -412,7 +412,7 @@ class MasqueradingKeyValueStore(KeyValueStore): This `KeyValueStore` wraps an underlying `KeyValueStore`. Reads are forwarded to the underlying store, but writes go to a Django session (or other dictionary-like object). """ - def __init__(self, kvs, session): + def __init__(self, kvs, session): # lint-amnesty, pylint: disable=super-init-not-called """ Arguments: kvs: The KeyValueStore to wrap. diff --git a/lms/djangoapps/courseware/model_data.py b/lms/djangoapps/courseware/model_data.py index f74dc1df7e..af372a49ff 100644 --- a/lms/djangoapps/courseware/model_data.py +++ b/lms/djangoapps/courseware/model_data.py @@ -109,7 +109,7 @@ class DjangoKeyValueStore(KeyValueStore): Scope.user_info, ) - def __init__(self, field_data_cache): + def __init__(self, field_data_cache): # lint-amnesty, pylint: disable=super-init-not-called self._field_data_cache = field_data_cache def get(self, key): diff --git a/lms/djangoapps/instructor/views/__init__.py b/lms/djangoapps/instructor/views/__init__.py index 2b14fd387e..83d462cd07 100644 --- a/lms/djangoapps/instructor/views/__init__.py +++ b/lms/djangoapps/instructor/views/__init__.py @@ -1,4 +1,4 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured This is the UserPreference key for the user's recipient invoice copy """ INVOICE_KEY = 'pref-invoice-copy' diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index 3cf21cd0d8..3f09cacf2a 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -16,7 +16,7 @@ import string import six import unicodecsv 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 MultipleObjectsReturned, ObjectDoesNotExist, PermissionDenied, ValidationError from django.core.validators import validate_email from django.db import IntegrityError, transaction @@ -44,7 +44,7 @@ from submissions import api as sub_api # installed from the edx-submissions rep from lms.djangoapps.instructor_analytics import basic as instructor_analytics_basic from lms.djangoapps.instructor_analytics import csvs as instructor_analytics_csvs -from lms.djangoapps.instructor_analytics import distributions as instructor_analytics_distributions +from lms.djangoapps.instructor_analytics import distributions as instructor_analytics_distributions # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.bulk_email.api import is_bulk_email_feature_enabled from lms.djangoapps.bulk_email.models import CourseEmail from common.djangoapps.course_modes.models import CourseMode @@ -337,7 +337,7 @@ def register_and_enroll_students(request, course_id): # pylint: disable=too-man try: upload_file = request.FILES.get('students_list') if upload_file.name.endswith('.csv'): - students = [row for row in csv.reader(upload_file.read().decode('utf-8').splitlines())] + students = [row for row in csv.reader(upload_file.read().decode('utf-8').splitlines())] # lint-amnesty, pylint: disable=unnecessary-comprehension course = get_course_by_id(course_id) else: general_errors.append({ @@ -434,7 +434,7 @@ def register_and_enroll_students(request, course_id): # pylint: disable=too-man 'email': email, 'response': _(u'Invalid email {email_address}.').format(email_address=email), }) - log.warning(u'Email address %s is associated with a retired user, so course enrollment was ' + + log.warning(u'Email address %s is associated with a retired user, so course enrollment was ' + # lint-amnesty, pylint: disable=logging-not-lazy u'blocked.', email) else: # This email does not yet exist, so we need to create a new account @@ -610,14 +610,14 @@ def create_and_enroll_user(email, username, name, country, password, course_id, @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_course_permission(permissions.CAN_ENROLL) @require_post_params(action="enroll or unenroll", identifiers="stringified list of emails and/or usernames") -def students_update_enrollment(request, course_id): +def students_update_enrollment(request, course_id): # lint-amnesty, pylint: disable=too-many-statements """ Enroll or unenroll students by email. Requires staff access. Query Parameters: - action in ['enroll', 'unenroll'] - - identifiers is string containing a list of emails and/or usernames separated by anything split_input_list can handle. + - identifiers is string containing a list of emails and/or usernames separated by anything split_input_list can handle. # lint-amnesty, pylint: disable=line-too-long - auto_enroll is a boolean (defaults to false) If auto_enroll is false, students will be allowed to enroll. If auto_enroll is true, students will be enrolled as soon as they register. @@ -675,7 +675,7 @@ def students_update_enrollment(request, course_id): email_params = get_email_params(course, auto_enroll, secure=request.is_secure()) results = [] - for identifier in identifiers: + for identifier in identifiers: # lint-amnesty, pylint: disable=too-many-nested-blocks # First try to get a user object from the identifer user = None email = None @@ -1052,7 +1052,7 @@ def get_problem_responses(request, course_id): try: for problem_location in problem_locations.split(','): - problem_key = UsageKey.from_string(problem_location).map_into_course(course_key) + problem_key = UsageKey.from_string(problem_location).map_into_course(course_key) # lint-amnesty, pylint: disable=unused-variable except InvalidKeyError: return JsonResponseBadRequest(_("Could not find problem with this location.")) @@ -1748,7 +1748,7 @@ def rescore_problem(request, course_id): @require_course_permission(permissions.OVERRIDE_GRADES) @require_post_params(problem_to_reset="problem urlname to reset", score='overriding score') @common_exceptions_400 -def override_problem_score(request, course_id): +def override_problem_score(request, course_id): # lint-amnesty, pylint: disable=missing-function-docstring course_key = CourseKey.from_string(course_id) score = strip_if_string(request.POST.get('score')) problem_to_reset = strip_if_string(request.POST.get('problem_to_reset')) @@ -2325,7 +2325,7 @@ def update_forum_role_membership(request, course_id): @require_POST -def get_user_invoice_preference(request, course_id): +def get_user_invoice_preference(request, course_id): # lint-amnesty, pylint: disable=unused-argument """ Gets invoice copy user's preferences. """ @@ -2691,7 +2691,7 @@ def remove_certificate_exception(course_key, student): try: certificate_exception = CertificateWhitelist.objects.get(user=student, course_id=course_key) except ObjectDoesNotExist: - raise ValueError( + raise ValueError( # lint-amnesty, pylint: disable=raise-missing-from _(u'Certificate exception (user={user}) does not exist in certificate white list. ' 'Please refresh the page and try again.').format(user=student.username) ) @@ -2744,7 +2744,7 @@ def parse_request_data(request): try: data = json.loads(request.body.decode('utf8') or u'{}') except ValueError: - raise ValueError(_('The record is not in the correct format. Please add a valid username or email address.')) + raise ValueError(_('The record is not in the correct format. Please add a valid username or email address.')) # lint-amnesty, pylint: disable=raise-missing-from return data @@ -2761,7 +2761,7 @@ def get_student(username_or_email, course_key): try: student = get_user_by_username_or_email(username_or_email) except ObjectDoesNotExist: - raise ValueError(_(u"{user} does not exist in the LMS. Please check your spelling and retry.").format( + raise ValueError(_(u"{user} does not exist in the LMS. Please check your spelling and retry.").format( # lint-amnesty, pylint: disable=raise-missing-from user=username_or_email )) @@ -2851,7 +2851,7 @@ def generate_bulk_certificate_exceptions(request, course_id): try: upload_file = request.FILES.get('students_list') if upload_file.name.endswith('.csv'): - students = [row for row in csv.reader(upload_file.read().decode('utf-8').splitlines())] + students = [row for row in csv.reader(upload_file.read().decode('utf-8').splitlines())] # lint-amnesty, pylint: disable=unnecessary-comprehension else: general_errors.append(_('Make sure that the file you upload is in CSV format with no ' 'extraneous characters or rows.')) @@ -3009,7 +3009,7 @@ def re_validate_certificate(request, course_key, generated_certificate): # Fetch CertificateInvalidation object certificate_invalidation = CertificateInvalidation.objects.get(generated_certificate=generated_certificate) except ObjectDoesNotExist: - raise ValueError(_("Certificate Invalidation does not exist, Please refresh the page and try again.")) + raise ValueError(_("Certificate Invalidation does not exist, Please refresh the page and try again.")) # lint-amnesty, pylint: disable=raise-missing-from else: # Deactivate certificate invalidation if it was fetched successfully. certificate_invalidation.deactivate() diff --git a/lms/djangoapps/instructor/views/gradebook_api.py b/lms/djangoapps/instructor/views/gradebook_api.py index 9a20ecdcbe..fb61ecdf1b 100644 --- a/lms/djangoapps/instructor/views/gradebook_api.py +++ b/lms/djangoapps/instructor/views/gradebook_api.py @@ -6,7 +6,7 @@ which is currently use by ccx and instructor apps. import math -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.urls import reverse from django.views.decorators.cache import cache_control diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index b75acb4d06..d24c9bc954 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -1,4 +1,4 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured Instructor Dashboard Views """ @@ -25,7 +25,7 @@ from mock import patch from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey from six import text_type -from six.moves.urllib.parse import urljoin +from six.moves.urllib.parse import urljoin # lint-amnesty, pylint: disable=unused-import from xblock.field_data import DictFieldData from xblock.fields import ScopeIds diff --git a/openedx/core/djangoapps/profile_images/urls.py b/openedx/core/djangoapps/profile_images/urls.py index d7062e8bf1..9383999b2b 100644 --- a/openedx/core/djangoapps/profile_images/urls.py +++ b/openedx/core/djangoapps/profile_images/urls.py @@ -1,4 +1,3 @@ -# lint-amnesty, pylint: disable=bad-option-value, unicode-format-string """ Defines the URL routes for this app. diff --git a/openedx/core/djangoapps/site_configuration/helpers.py b/openedx/core/djangoapps/site_configuration/helpers.py index a910c4fb71..a4bf26660f 100644 --- a/openedx/core/djangoapps/site_configuration/helpers.py +++ b/openedx/core/djangoapps/site_configuration/helpers.py @@ -1,4 +1,4 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured Helpers methods for site configuration. """ diff --git a/openedx/core/djangoapps/user_authn/utils.py b/openedx/core/djangoapps/user_authn/utils.py index 238f2ac770..2bf24cd81e 100644 --- a/openedx/core/djangoapps/user_authn/utils.py +++ b/openedx/core/djangoapps/user_authn/utils.py @@ -10,7 +10,7 @@ from django.utils import http from oauth2_provider.models import Application from six.moves.urllib.parse import urlparse # pylint: disable=import-error -from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers +from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers # lint-amnesty, pylint: disable=unused-import def is_safe_login_or_logout_redirect(redirect_to, request_host, dot_client_id, require_https):