From 1a5bf353574934001017c39bafda2b4cfe6de38d Mon Sep 17 00:00:00 2001 From: Jeremy Bowman Date: Tue, 14 Aug 2018 16:37:25 -0400 Subject: [PATCH] TE-2689 Remove useless pylint suppressions part 2 --- lms/djangoapps/badges/api/tests.py | 8 ------- .../badges/events/tests/test_course_meta.py | 11 ---------- lms/djangoapps/badges/models.py | 3 +-- lms/djangoapps/badges/tests/test_models.py | 2 +- lms/djangoapps/bulk_email/models.py | 11 +++++----- lms/djangoapps/bulk_email/tasks.py | 6 ++--- .../bulk_email/tests/test_err_handling.py | 2 +- lms/djangoapps/bulk_email/tests/test_tasks.py | 2 +- lms/djangoapps/certificates/views/support.py | 4 ++-- .../commerce/api/v0/tests/test_views.py | 4 ++-- .../management/commands/configure_commerce.py | 2 +- lms/djangoapps/commerce/tests/__init__.py | 2 +- lms/djangoapps/commerce/utils.py | 2 +- .../course_api/blocks/tests/test_views.py | 2 +- .../course_api/tests/test_serializers.py | 4 ++-- lms/djangoapps/course_api/tests/test_views.py | 8 +++---- .../transformers/library_content.py | 2 +- .../transformers/tests/test_start_date.py | 1 - .../course_blocks/transformers/utils.py | 2 +- lms/djangoapps/course_goals/models.py | 2 +- lms/djangoapps/course_wiki/editors.py | 2 +- .../plugins/markdownedx/mdx_video.py | 2 +- lms/djangoapps/discussion/tests/test_views.py | 10 ++------- lms/djangoapps/discussion/views.py | 2 +- lms/djangoapps/edxnotes/tests.py | 1 - lms/djangoapps/email_marketing/apps.py | 2 +- lms/djangoapps/email_marketing/tasks.py | 2 -- lms/djangoapps/grades/api/tests/test_views.py | 2 -- lms/djangoapps/grades/config/models.py | 1 - lms/djangoapps/grades/models.py | 2 +- .../grades/tests/integration/test_events.py | 1 - lms/djangoapps/grades/tests/test_scores.py | 1 - .../grades/tests/test_transformer.py | 2 +- lms/djangoapps/instructor/tests/test_api.py | 4 ++-- .../instructor/tests/test_certificates.py | 10 ++++----- .../instructor/tests/test_enrollment.py | 1 - .../tests/views/test_instructor_dashboard.py | 2 +- lms/djangoapps/instructor/views/api.py | 12 +++++----- .../instructor/views/instructor_dashboard.py | 6 ++--- lms/djangoapps/shoppingcart/exceptions.py | 2 -- lms/djangoapps/shoppingcart/models.py | 10 ++++----- .../shoppingcart/tests/test_models.py | 4 ++-- .../shoppingcart/tests/test_views.py | 22 +++++++++---------- lms/djangoapps/support/decorators.py | 2 +- lms/djangoapps/support/tests/test_refund.py | 2 +- lms/djangoapps/support/tests/test_views.py | 22 +++++++++---------- lms/envs/acceptance.py | 2 +- lms/envs/bok_choy.py | 2 +- lms/envs/common.py | 5 ++--- lms/envs/devstack_optimized.py | 2 +- lms/envs/test.py | 5 ----- scripts/thresholds.sh | 2 +- 52 files changed, 90 insertions(+), 137 deletions(-) diff --git a/lms/djangoapps/badges/api/tests.py b/lms/djangoapps/badges/api/tests.py index e242203f7d..d34a4cf090 100644 --- a/lms/djangoapps/badges/api/tests.py +++ b/lms/djangoapps/badges/api/tests.py @@ -101,14 +101,12 @@ class TestUserBadgeAssertions(UserAssertionTestCase): for dummy in range(3): self.create_badge_class(False) response = self.get_json(self.url()) - # pylint: disable=no-member self.assertEqual(len(response['results']), 4) def test_assertion_structure(self): badge_class = self.create_badge_class(False) assertion = BadgeAssertionFactory.create(user=self.user, badge_class=badge_class) response = self.get_json(self.url()) - # pylint: disable=no-member self.check_assertion_structure(assertion, response['results'][0]) @@ -132,11 +130,9 @@ class TestUserCourseBadgeAssertions(UserAssertionTestCase): for dummy in range(6): BadgeAssertionFactory.create(badge_class=badge_class) response = self.get_json(self.url(), data={'course_id': course_key}) - # pylint: disable=no-member self.assertEqual(len(response['results']), 3) unused_course = CourseFactory.create() response = self.get_json(self.url(), data={'course_id': unused_course.location.course_key}) - # pylint: disable=no-member self.assertEqual(len(response['results']), 0) def test_assertion_structure(self): @@ -147,7 +143,6 @@ class TestUserCourseBadgeAssertions(UserAssertionTestCase): badge_class = BadgeClassFactory.create(course_id=course_key) assertion = BadgeAssertionFactory.create(badge_class=badge_class, user=self.user) response = self.get_json(self.url()) - # pylint: disable=no-member self.check_assertion_structure(assertion, response['results'][0]) @@ -189,7 +184,6 @@ class TestUserBadgeAssertionsByClass(UserAssertionTestCase): expected_length = 4 else: expected_length = 3 - # pylint: disable=no-member self.assertEqual(len(response['results']), expected_length) unused_class = self.create_badge_class(check_course, slug='unused_slug', issuing_component='unused_component') @@ -197,7 +191,6 @@ class TestUserBadgeAssertionsByClass(UserAssertionTestCase): self.url(), data=self.get_qs_args(check_course, wildcard, unused_class), ) - # pylint: disable=no-member self.assertEqual(len(response['results']), 0) def check_badge_class_assertion(self, check_course, wildcard, badge_class): @@ -209,7 +202,6 @@ class TestUserBadgeAssertionsByClass(UserAssertionTestCase): self.url(), data=self.get_qs_args(check_course, wildcard, badge_class), ) - # pylint: disable=no-member self.check_assertion_structure(assertion, response['results'][0]) @unpack diff --git a/lms/djangoapps/badges/events/tests/test_course_meta.py b/lms/djangoapps/badges/events/tests/test_course_meta.py index 2d0eb998ff..d67e70f4f8 100644 --- a/lms/djangoapps/badges/events/tests/test_course_meta.py +++ b/lms/djangoapps/badges/events/tests/test_course_meta.py @@ -47,7 +47,6 @@ class CourseEnrollmentBadgeTest(ModuleStoreTestCase): """ user = UserFactory() course = CourseFactory() - # pylint: disable=no-member CourseEnrollment.enroll(user, course_key=course.location.course_key) self.assertFalse(user.badgeassertion_set.all()) @@ -61,7 +60,6 @@ class CourseEnrollmentBadgeTest(ModuleStoreTestCase): courses = [CourseFactory() for _i in range(required_badges)] for course in courses: CourseEnrollment.enroll(user, course_key=course.location.course_key) - # pylint: disable=no-member assertions = user.badgeassertion_set.all().order_by('id') self.assertEqual(user.badgeassertion_set.all().count(), checkpoint) self.assertEqual(assertions[checkpoint - 1].badge_class, self.badge_classes[checkpoint - 1]) @@ -102,10 +100,8 @@ class CourseCompletionBadgeTest(ModuleStoreTestCase): user = UserFactory() course = CourseFactory() GeneratedCertificate( - # pylint: disable=no-member user=user, course_id=course.location.course_key, status=CertificateStatuses.downloadable ).save() - # pylint: disable=no-member self.assertFalse(user.badgeassertion_set.all()) @unpack @@ -118,12 +114,9 @@ class CourseCompletionBadgeTest(ModuleStoreTestCase): courses = [CourseFactory() for _i in range(required_badges)] for course in courses: GeneratedCertificate( - # pylint: disable=no-member user=user, course_id=course.location.course_key, status=CertificateStatuses.downloadable ).save() - # pylint: disable=no-member assertions = user.badgeassertion_set.all().order_by('id') - # pylint: disable=no-member self.assertEqual(user.badgeassertion_set.all().count(), checkpoint) self.assertEqual(assertions[checkpoint - 1].badge_class, self.badge_classes[checkpoint - 1]) @@ -151,7 +144,6 @@ class CourseGroupBadgeTest(ModuleStoreTestCase): ] self.courses = [] for _badge_class in self.badge_classes: - # pylint: disable=no-member self.courses.append([CourseFactory().location.course_key for _i in range(3)]) lines = [badge_class.slug + ',' + ','.join([unicode(course_key) for course_key in keys]) for badge_class, keys in zip(self.badge_classes, self.courses)] @@ -166,10 +158,8 @@ class CourseGroupBadgeTest(ModuleStoreTestCase): user = UserFactory() course = CourseFactory() GeneratedCertificate( - # pylint: disable=no-member user=user, course_id=course.location.course_key, status=CertificateStatuses.downloadable ).save() - # pylint: disable=no-member self.assertFalse(user.badgeassertion_set.all()) def test_group_matches(self): @@ -188,7 +178,6 @@ class CourseGroupBadgeTest(ModuleStoreTestCase): self.assertTrue(badge_class.get_for_user(user)) else: self.assertFalse(badge_class.get_for_user(user)) - # pylint: disable=no-member classes = [badge.badge_class.id for badge in user.badgeassertion_set.all()] source_classes = [badge.id for badge in self.badge_classes] self.assertEqual(classes, source_classes) diff --git a/lms/djangoapps/badges/models.py b/lms/djangoapps/badges/models.py index 79709e4df5..619065374b 100644 --- a/lms/djangoapps/badges/models.py +++ b/lms/djangoapps/badges/models.py @@ -168,7 +168,7 @@ class BadgeAssertion(TimeStampedModel): # Abstract model doesn't index this, so we have to. -BadgeAssertion._meta.get_field('created').db_index = True # pylint: disable=protected-access +BadgeAssertion._meta.get_field('created').db_index = True class CourseCompleteImageConfiguration(models.Model): @@ -206,7 +206,6 @@ class CourseCompleteImageConfiguration(models.Model): """ Make sure there's not more than one default. """ - # pylint: disable=no-member if self.default and CourseCompleteImageConfiguration.objects.filter(default=True).exclude(id=self.id): raise ValidationError(_(u"There can be only one default image.")) diff --git a/lms/djangoapps/badges/tests/test_models.py b/lms/djangoapps/badges/tests/test_models.py index 4fc3217eb8..ca0a8b2e10 100644 --- a/lms/djangoapps/badges/tests/test_models.py +++ b/lms/djangoapps/badges/tests/test_models.py @@ -83,7 +83,7 @@ class BadgeClassTest(ModuleStoreTestCase): """ Remove all files uploaded as badges. """ - upload_to = BadgeClass._meta.get_field('image').upload_to # pylint: disable=protected-access + upload_to = BadgeClass._meta.get_field('image').upload_to if default_storage.exists(upload_to): (_, files) = default_storage.listdir(upload_to) for uploaded_file in files: diff --git a/lms/djangoapps/bulk_email/models.py b/lms/djangoapps/bulk_email/models.py index 03f194547b..13a1ef09b3 100644 --- a/lms/djangoapps/bulk_email/models.py +++ b/lms/djangoapps/bulk_email/models.py @@ -79,9 +79,9 @@ class Target(models.Model): Returns a short display name """ if self.target_type == SEND_TO_COHORT: - return self.cohorttarget.short_display() # pylint: disable=no-member + return self.cohorttarget.short_display() elif self.target_type == SEND_TO_TRACK: - return self.coursemodetarget.short_display() # pylint: disable=no-member + return self.coursemodetarget.short_display() else: return self.target_type @@ -90,9 +90,9 @@ class Target(models.Model): Returns a long display name """ if self.target_type == SEND_TO_COHORT: - return self.cohorttarget.long_display() # pylint: disable=no-member + return self.cohorttarget.long_display() elif self.target_type == SEND_TO_TRACK: - return self.coursemodetarget.long_display() # pylint: disable=no-member + return self.coursemodetarget.long_display() else: return self.get_target_type_display() @@ -123,7 +123,7 @@ class Target(models.Model): enrollment_qset.exclude(id__in=staff_instructor_qset) ) elif self.target_type == SEND_TO_COHORT: - return self.cohorttarget.cohort.users.filter(id__in=enrollment_qset) # pylint: disable=no-member + return self.cohorttarget.cohort.users.filter(id__in=enrollment_qset) elif self.target_type == SEND_TO_TRACK: return use_read_replica_if_available( User.objects.filter( @@ -432,7 +432,6 @@ class CourseAuthorization(models.Model): not_en = "Not " if self.email_enabled: not_en = "" - # pylint: disable=no-member return u"Course '{}': Instructor Email {}Enabled".format(text_type(self.course_id), not_en) diff --git a/lms/djangoapps/bulk_email/tasks.py b/lms/djangoapps/bulk_email/tasks.py index 3526303d3c..01c29d31ad 100644 --- a/lms/djangoapps/bulk_email/tasks.py +++ b/lms/djangoapps/bulk_email/tasks.py @@ -23,9 +23,9 @@ from boto.ses.exceptions import ( SESLocalAddressCharacterError, SESMaxSendingRateExceededError ) -from celery import current_task, task # pylint: disable=no-name-in-module -from celery.exceptions import RetryTaskError # pylint: disable=no-name-in-module, import-error -from celery.states import FAILURE, RETRY, SUCCESS # pylint: disable=no-name-in-module, import-error +from celery import current_task, task +from celery.exceptions import RetryTaskError +from celery.states import FAILURE, RETRY, SUCCESS from django.conf import settings from django.contrib.auth.models import User from django.core.mail import EmailMultiAlternatives, get_connection diff --git a/lms/djangoapps/bulk_email/tests/test_err_handling.py b/lms/djangoapps/bulk_email/tests/test_err_handling.py index 4529b9d54c..e0c8f624a5 100644 --- a/lms/djangoapps/bulk_email/tests/test_err_handling.py +++ b/lms/djangoapps/bulk_email/tests/test_err_handling.py @@ -7,7 +7,7 @@ from itertools import cycle from smtplib import SMTPConnectError, SMTPDataError, SMTPServerDisconnected import ddt -from celery.states import RETRY, SUCCESS # pylint: disable=no-name-in-module, import-error +from celery.states import RETRY, SUCCESS from django.conf import settings from django.core.management import call_command from django.urls import reverse diff --git a/lms/djangoapps/bulk_email/tests/test_tasks.py b/lms/djangoapps/bulk_email/tests/test_tasks.py index ca6eb61adf..9a565ffc89 100644 --- a/lms/djangoapps/bulk_email/tests/test_tasks.py +++ b/lms/djangoapps/bulk_email/tests/test_tasks.py @@ -23,7 +23,7 @@ from boto.ses.exceptions import ( SESLocalAddressCharacterError, SESMaxSendingRateExceededError ) -from celery.states import FAILURE, SUCCESS # pylint: disable=no-name-in-module, import-error +from celery.states import FAILURE, SUCCESS from django.conf import settings from django.core.management import call_command from mock import Mock, patch diff --git a/lms/djangoapps/certificates/views/support.py b/lms/djangoapps/certificates/views/support.py index dc09eb07df..cd7db790b4 100644 --- a/lms/djangoapps/certificates/views/support.py +++ b/lms/djangoapps/certificates/views/support.py @@ -33,7 +33,7 @@ def require_certificate_permission(func): View decorator that requires permission to view and regenerate certificates. """ @wraps(func) - def inner(request, *args, **kwargs): # pylint:disable=missing-docstring + def inner(request, *args, **kwargs): if has_access(request.user, "certificates", "global"): return func(request, *args, **kwargs) else: @@ -285,5 +285,5 @@ def _deactivate_invalidation(certificate): ) # Deactivate certificate invalidation if it was fetched successfully. certificate_invalidation.deactivate() - except CertificateInvalidation.DoesNotExist: # pylint: disable=bare-except + except CertificateInvalidation.DoesNotExist: pass diff --git a/lms/djangoapps/commerce/api/v0/tests/test_views.py b/lms/djangoapps/commerce/api/v0/tests/test_views.py index cd884fb16e..7870b79a64 100644 --- a/lms/djangoapps/commerce/api/v0/tests/test_views.py +++ b/lms/djangoapps/commerce/api/v0/tests/test_views.py @@ -135,7 +135,7 @@ class BasketsViewTests(EnrollmentEventTestMixin, UserMixin, ModuleStoreTestCase) """ # Set user's active flag self.user.is_active = user_is_active - self.user.save() # pylint: disable=no-member + self.user.save() response = self._post_to_view() # Validate the response content @@ -275,7 +275,7 @@ class BasketsViewTests(EnrollmentEventTestMixin, UserMixin, ModuleStoreTestCase) Verifies that the view returns HTTP 406 when a course is closed. """ self.course.enrollment_end = datetime.now(pytz.UTC) - timedelta(days=1) - modulestore().update_item(self.course, self.user.id) # pylint:disable=no-member + modulestore().update_item(self.course, self.user.id) self.assertEqual(self._post_to_view().status_code, 406) diff --git a/lms/djangoapps/commerce/management/commands/configure_commerce.py b/lms/djangoapps/commerce/management/commands/configure_commerce.py index df27a5d3db..05c765c654 100644 --- a/lms/djangoapps/commerce/management/commands/configure_commerce.py +++ b/lms/djangoapps/commerce/management/commands/configure_commerce.py @@ -54,7 +54,7 @@ class Command(BaseCommand): checkout_on_ecommerce = options.get('checkout_on_ecommerce') # We are keeping id=1, because as of now, there are only one commerce configuration for the system. - CommerceConfiguration.objects.update_or_create( # pylint: disable=no-member + CommerceConfiguration.objects.update_or_create( id=1, defaults={ 'enabled': not disable, diff --git a/lms/djangoapps/commerce/tests/__init__.py b/lms/djangoapps/commerce/tests/__init__.py index 82df849ba3..4ae655e335 100644 --- a/lms/djangoapps/commerce/tests/__init__.py +++ b/lms/djangoapps/commerce/tests/__init__.py @@ -57,7 +57,7 @@ class EdxRestApiClientTest(TestCase): claims = { 'tracking_context': { - 'lms_user_id': self.user.id, # pylint: disable=no-member + 'lms_user_id': self.user.id, 'lms_client_id': self.TEST_CLIENT_ID, 'lms_ip': '127.0.0.1', } diff --git a/lms/djangoapps/commerce/utils.py b/lms/djangoapps/commerce/utils.py index 9d8c69d80e..cac8e06767 100644 --- a/lms/djangoapps/commerce/utils.py +++ b/lms/djangoapps/commerce/utils.py @@ -340,7 +340,7 @@ def _send_refund_notification(user, refund_ids): return create_zendesk_ticket(requester_name, student.email, subject, body, tags) -def _generate_refund_notification_body(student, refund_ids): # pylint: disable=invalid-name +def _generate_refund_notification_body(student, refund_ids): """ Returns a refund notification message body. """ msg = _( 'A refund request has been initiated for {username} ({email}). ' diff --git a/lms/djangoapps/course_api/blocks/tests/test_views.py b/lms/djangoapps/course_api/blocks/tests/test_views.py index 427b85fdcc..241fc015ae 100644 --- a/lms/djangoapps/course_api/blocks/tests/test_views.py +++ b/lms/djangoapps/course_api/blocks/tests/test_views.py @@ -247,7 +247,7 @@ class TestBlocksView(SharedModuleStoreTestCase): self.verify_response_with_requested_fields(response) -class TestBlocksInCourseView(TestBlocksView): # pylint: disable=test-inherits-tests +class TestBlocksInCourseView(TestBlocksView): """ Test class for BlocksInCourseView """ diff --git a/lms/djangoapps/course_api/tests/test_serializers.py b/lms/djangoapps/course_api/tests/test_serializers.py index dac4f2bab5..770ea18754 100644 --- a/lms/djangoapps/course_api/tests/test_serializers.py +++ b/lms/djangoapps/course_api/tests/test_serializers.py @@ -96,7 +96,7 @@ class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase): def test_basic(self): course = self.create_course() - CourseDetails.update_about_video(course, 'test_youtube_id', self.staff_user.id) # pylint: disable=no-member + CourseDetails.update_about_video(course, 'test_youtube_id', self.staff_user.id) with check_mongo_calls(self.expected_mongo_calls): result = self._get_result(course) self.assertDictEqual(result, self.expected_data) @@ -139,7 +139,7 @@ class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase): self.assertEqual(result['pacing'], expected_pacing) -class TestCourseDetailSerializer(TestCourseSerializer): # pylint: disable=test-inherits-tests +class TestCourseDetailSerializer(TestCourseSerializer): """ Test CourseDetailSerializer by rerunning all the tests in TestCourseSerializer, but with the diff --git a/lms/djangoapps/course_api/tests/test_views.py b/lms/djangoapps/course_api/tests/test_views.py index 26d74e02b4..974752be37 100644 --- a/lms/djangoapps/course_api/tests/test_views.py +++ b/lms/djangoapps/course_api/tests/test_views.py @@ -98,7 +98,7 @@ class CourseListViewTestCase(CourseApiTestViewMixin, SharedModuleStoreTestCase): def test_missing_username(self): self.setup_user(self.honor_user) response_to_missing_username = self.verify_response(expected_status_code=200) - self.assertIsNotNone(response_to_missing_username.data) # pylint: disable=no-member + self.assertIsNotNone(response_to_missing_username.data) def test_not_logged_in(self): self.client.logout() @@ -167,13 +167,13 @@ class CourseListViewTestCaseMultipleCourses(CourseApiTestViewMixin, ModuleStoreT unfiltered_response = self.verify_response(params={'username': self.staff_user.username}) for org in [self.course.org, alternate_course.org]: self.assertTrue( - any(course['org'] == org for course in unfiltered_response.data['results']) # pylint: disable=no-member + any(course['org'] == org for course in unfiltered_response.data['results']) ) # With filtering. filtered_response = self.verify_response(params={'org': self.course.org, 'username': self.staff_user.username}) self.assertTrue( - all(course['org'] == self.course.org for course in filtered_response.data['results']) # pylint: disable=no-member + all(course['org'] == self.course.org for course in filtered_response.data['results']) ) def test_filter(self): @@ -193,7 +193,7 @@ class CourseListViewTestCaseMultipleCourses(CourseApiTestViewMixin, ModuleStoreT params.update(filter_) response = self.verify_response(params=params) self.assertEquals( - {course['course_id'] for course in response.data['results']}, # pylint: disable=no-member + {course['course_id'] for course in response.data['results']}, {unicode(course.id) for course in expected_courses}, "testing course_api.views.CourseListView with filter_={}".format(filter_), ) diff --git a/lms/djangoapps/course_blocks/transformers/library_content.py b/lms/djangoapps/course_blocks/transformers/library_content.py index 1ab71ca32b..eb893a459d 100644 --- a/lms/djangoapps/course_blocks/transformers/library_content.py +++ b/lms/djangoapps/course_blocks/transformers/library_content.py @@ -98,7 +98,7 @@ class ContentLibraryTransformer(FilteringTransformerMixin, BlockStructureTransfo # Save back any changes if any(block_keys[changed] for changed in ('invalid', 'overlimit', 'added')): state_dict['selected'] = list(selected) - StudentModule.objects.update_or_create( # pylint: disable=no-member + StudentModule.objects.update_or_create( student=usage_info.user, course_id=usage_info.course_key, module_state_key=block_key, diff --git a/lms/djangoapps/course_blocks/transformers/tests/test_start_date.py b/lms/djangoapps/course_blocks/transformers/tests/test_start_date.py index a9ddea6c0b..5ff94031e3 100644 --- a/lms/djangoapps/course_blocks/transformers/tests/test_start_date.py +++ b/lms/djangoapps/course_blocks/transformers/tests/test_start_date.py @@ -101,7 +101,6 @@ class StartDateTransformerTestCase(BlockParentsMapTestCase): (BETA_USER, {0: StartDateType.released, 4: StartDateType.default}, {0, 1, 2, 3, 5, 6}, {6}), ) @ddt.unpack - # pylint: disable=invalid-name def test_block_start_date( self, user_type, diff --git a/lms/djangoapps/course_blocks/transformers/utils.py b/lms/djangoapps/course_blocks/transformers/utils.py index c9c7ca55bb..ffc988428a 100644 --- a/lms/djangoapps/course_blocks/transformers/utils.py +++ b/lms/djangoapps/course_blocks/transformers/utils.py @@ -77,7 +77,7 @@ def collect_merged_boolean_field( for block_key in block_structure.topological_traversal(): # compute merged value of the boolean field from all parents parents = block_structure.get_parents(block_key) - all_parents_merged_value = all( # pylint: disable=invalid-name + all_parents_merged_value = all( block_structure.get_transformer_block_field( parent_key, transformer, merged_field_name, False, ) diff --git a/lms/djangoapps/course_goals/models.py b/lms/djangoapps/course_goals/models.py index b0bc820864..366dbfa470 100644 --- a/lms/djangoapps/course_goals/models.py +++ b/lms/djangoapps/course_goals/models.py @@ -42,7 +42,7 @@ class CourseGoal(models.Model): @receiver(models.signals.post_save, sender=CourseEnrollment, dispatch_uid="update_course_goal_on_enroll_change") -def update_course_goal_on_enroll_change(sender, instance, **kwargs): # pylint: disable=unused-argument, invalid-name +def update_course_goal_on_enroll_change(sender, instance, **kwargs): # pylint: disable=unused-argument """ Updates goals as follows on enrollment changes: 1) Set the course goal to 'certify' when the user enrolls as a verified user. diff --git a/lms/djangoapps/course_wiki/editors.py b/lms/djangoapps/course_wiki/editors.py index ea82427e18..c02e3bf887 100644 --- a/lms/djangoapps/course_wiki/editors.py +++ b/lms/djangoapps/course_wiki/editors.py @@ -66,7 +66,7 @@ class CodeMirror(BaseEditor): "wiki/markitup/sets/admin/set.js", ) - class Media(object): # pylint: disable=missing-docstring + class Media(object): css = { 'all': ("js/vendor/CodeMirror/codemirror.css",) } diff --git a/lms/djangoapps/course_wiki/plugins/markdownedx/mdx_video.py b/lms/djangoapps/course_wiki/plugins/markdownedx/mdx_video.py index 3309645428..8a13b800de 100755 --- a/lms/djangoapps/course_wiki/plugins/markdownedx/mdx_video.py +++ b/lms/djangoapps/course_wiki/plugins/markdownedx/mdx_video.py @@ -135,7 +135,7 @@ try: # but import the 2.0.3 version if it fails from markdown.util import etree except ImportError: - from markdown import etree # pylint: disable=no-name-in-module + from markdown import etree version = "0.1.6" diff --git a/lms/djangoapps/discussion/tests/test_views.py b/lms/djangoapps/discussion/tests/test_views.py index 2030c75d15..dd29291dc3 100644 --- a/lms/djangoapps/discussion/tests/test_views.py +++ b/lms/djangoapps/discussion/tests/test_views.py @@ -899,7 +899,7 @@ class InlineDiscussionContextTestCase(ForumsEnableMixin, ModuleStoreTestCase): discussion_topic_id=self.discussion_topic_id ) - self.team.add_user(self.user) # pylint: disable=no-member + self.team.add_user(self.user) def test_context_can_be_standalone(self, mock_request): mock_request.side_effect = make_mock_request_impl( @@ -1261,7 +1261,7 @@ class InlineDiscussionTestCase(ForumsEnableMixin, ModuleStoreTestCase): discussion_topic_id=self.discussion1.discussion_id ) - team.add_user(self.student) # pylint: disable=no-member + team.add_user(self.student) response = self.send_request(mock_request) self.assertEqual(mock_request.call_args[1]['params']['context'], ThreadContext.STANDALONE) @@ -1470,7 +1470,6 @@ class InlineDiscussionUnicodeTestCase(ForumsEnableMixin, SharedModuleStoreTestCa @classmethod def setUpClass(cls): - # pylint: disable=super-method-not-called with super(InlineDiscussionUnicodeTestCase, cls).setUpClassAndTestData(): cls.course = CourseFactory.create() @@ -1504,7 +1503,6 @@ class ForumFormDiscussionUnicodeTestCase(ForumsEnableMixin, SharedModuleStoreTes @classmethod def setUpClass(cls): - # pylint: disable=super-method-not-called with super(ForumFormDiscussionUnicodeTestCase, cls).setUpClassAndTestData(): cls.course = CourseFactory.create() @@ -1594,7 +1592,6 @@ class ForumDiscussionSearchUnicodeTestCase(ForumsEnableMixin, SharedModuleStoreT @classmethod def setUpClass(cls): - # pylint: disable=super-method-not-called with super(ForumDiscussionSearchUnicodeTestCase, cls).setUpClassAndTestData(): cls.course = CourseFactory.create() @@ -1631,7 +1628,6 @@ class SingleThreadUnicodeTestCase(ForumsEnableMixin, SharedModuleStoreTestCase, @classmethod def setUpClass(cls): - # pylint: disable=super-method-not-called with super(SingleThreadUnicodeTestCase, cls).setUpClassAndTestData(): cls.course = CourseFactory.create(discussion_topics={'dummy_discussion_id': {'id': 'dummy_discussion_id'}}) @@ -1665,7 +1661,6 @@ class UserProfileUnicodeTestCase(ForumsEnableMixin, SharedModuleStoreTestCase, U @classmethod def setUpClass(cls): - # pylint: disable=super-method-not-called with super(UserProfileUnicodeTestCase, cls).setUpClassAndTestData(): cls.course = CourseFactory.create() @@ -1698,7 +1693,6 @@ class FollowedThreadsUnicodeTestCase(ForumsEnableMixin, SharedModuleStoreTestCas @classmethod def setUpClass(cls): - # pylint: disable=super-method-not-called with super(FollowedThreadsUnicodeTestCase, cls).setUpClassAndTestData(): cls.course = CourseFactory.create() diff --git a/lms/djangoapps/discussion/views.py b/lms/djangoapps/discussion/views.py index 064db20609..b0dbdb4b9d 100644 --- a/lms/djangoapps/discussion/views.py +++ b/lms/djangoapps/discussion/views.py @@ -180,7 +180,7 @@ def use_bulk_ops(view_func): the request uri to a CourseKey before passing to the view. """ @wraps(view_func) - def wrapped_view(request, course_id, *args, **kwargs): # pylint: disable=missing-docstring + def wrapped_view(request, course_id, *args, **kwargs): course_key = CourseKey.from_string(course_id) with modulestore().bulk_operations(course_key): return view_func(request, course_key, *args, **kwargs) diff --git a/lms/djangoapps/edxnotes/tests.py b/lms/djangoapps/edxnotes/tests.py index fed82de63b..f5fcfabe80 100644 --- a/lms/djangoapps/edxnotes/tests.py +++ b/lms/djangoapps/edxnotes/tests.py @@ -913,7 +913,6 @@ class EdxNotesHelpersTest(ModuleStoreTestCase): Verify that `construct_url` works correctly. """ # make absolute url - # pylint: disable=no-member if self.request.is_secure(): host = 'https://' + self.request.get_host() else: diff --git a/lms/djangoapps/email_marketing/apps.py b/lms/djangoapps/email_marketing/apps.py index 090467fff1..89f4c97bfc 100644 --- a/lms/djangoapps/email_marketing/apps.py +++ b/lms/djangoapps/email_marketing/apps.py @@ -13,4 +13,4 @@ class EmailMarketingConfig(AppConfig): def ready(self): # Register the signal handlers. - from . import signals # pylint: disable=unused-import + from . import signals # pylint: disable=unused-variable diff --git a/lms/djangoapps/email_marketing/tasks.py b/lms/djangoapps/email_marketing/tasks.py index 4221cd4d2a..a1ac755d5d 100644 --- a/lms/djangoapps/email_marketing/tasks.py +++ b/lms/djangoapps/email_marketing/tasks.py @@ -59,7 +59,6 @@ def get_email_cookies_via_sailthru(self, user_email, post_parms): return None -# pylint: disable=not-callable @task(bind=True, default_retry_delay=3600, max_retries=24, routing_key=ACE_ROUTING_KEY) def update_user(self, sailthru_vars, email, site=None, new_user=False, activation=False): """ @@ -135,7 +134,6 @@ def is_default_site(site): return not site or site.get('id') == settings.SITE_ID -# pylint: disable=not-callable @task(bind=True, default_retry_delay=3600, max_retries=24, routing_key=ACE_ROUTING_KEY) def update_user_email(self, new_email, old_email): """ diff --git a/lms/djangoapps/grades/api/tests/test_views.py b/lms/djangoapps/grades/api/tests/test_views.py index 311ad02044..420cb6882e 100644 --- a/lms/djangoapps/grades/api/tests/test_views.py +++ b/lms/djangoapps/grades/api/tests/test_views.py @@ -318,14 +318,12 @@ class GradingPolicyTestMixin(object): self.create_user_and_access_token() def create_user_and_access_token(self): - # pylint: disable=missing-docstring self.user = GlobalStaffFactory.create() self.oauth_client = ClientFactory.create() self.access_token = AccessTokenFactory.create(user=self.user, client=self.oauth_client).token @classmethod def create_course_data(cls): - # pylint: disable=missing-docstring cls.invalid_course_id = 'foo/bar/baz' cls.course = CourseFactory.create(display_name='An Introduction to API Testing', raw_grader=cls.raw_grader) cls.course_id = unicode(cls.course.id) diff --git a/lms/djangoapps/grades/config/models.py b/lms/djangoapps/grades/config/models.py index 7e385807fe..485d9bc0e7 100644 --- a/lms/djangoapps/grades/config/models.py +++ b/lms/djangoapps/grades/config/models.py @@ -71,7 +71,6 @@ class CoursePersistentGradesFlag(ConfigurationModel): not_en = "Not " if self.enabled: not_en = "" - # pylint: disable=no-member return u"Course '{}': Persistent Grades {}Enabled".format(text_type(self.course_id), not_en) diff --git a/lms/djangoapps/grades/models.py b/lms/djangoapps/grades/models.py index b19301dff4..cdb557fa5c 100644 --- a/lms/djangoapps/grades/models.py +++ b/lms/djangoapps/grades/models.py @@ -314,7 +314,7 @@ class PersistentSubsectionGrade(TimeStampedModel): """ Returns the "correct" usage key value with the run filled in. """ - if self.usage_key.run is None: # pylint: disable=no-member + if self.usage_key.run is None: return self.usage_key.replace(course_key=self.course_id) else: return self.usage_key diff --git a/lms/djangoapps/grades/tests/integration/test_events.py b/lms/djangoapps/grades/tests/integration/test_events.py index a2d83ccb50..66f08a0c80 100644 --- a/lms/djangoapps/grades/tests/integration/test_events.py +++ b/lms/djangoapps/grades/tests/integration/test_events.py @@ -1,7 +1,6 @@ """ Test grading events across apps. """ -# pylint: disable=protected-access from mock import call as mock_call, patch diff --git a/lms/djangoapps/grades/tests/test_scores.py b/lms/djangoapps/grades/tests/test_scores.py index 6c18a03627..a66ed3d586 100644 --- a/lms/djangoapps/grades/tests/test_scores.py +++ b/lms/djangoapps/grades/tests/test_scores.py @@ -326,7 +326,6 @@ class TestInternalGetScoreFromBlock(TestCase): """ Verifies the result of _get_score_from_persisted_or_latest_block is as expected. """ - # pylint: disable=unbalanced-tuple-unpacking ( raw_earned, raw_possible, weighted_earned, weighted_possible, first_attempted ) = scores._get_score_from_persisted_or_latest_block(persisted_block, block, weight) diff --git a/lms/djangoapps/grades/tests/test_transformer.py b/lms/djangoapps/grades/tests/test_transformer.py index 6097aeac1f..24bc3fe316 100644 --- a/lms/djangoapps/grades/tests/test_transformer.py +++ b/lms/djangoapps/grades/tests/test_transformer.py @@ -93,7 +93,7 @@ class GradesTransformerTestCase(CourseStructureTestCase): """ self.assertGreater(len(expectations), 0) # Append our custom message to the default assertEqual error message - self.longMessage = True # pylint: disable=invalid-name + self.longMessage = True for field in expectations: self.assertEqual( expectations[field], diff --git a/lms/djangoapps/instructor/tests/test_api.py b/lms/djangoapps/instructor/tests/test_api.py index 29d0df8ced..cd11d51ccd 100644 --- a/lms/djangoapps/instructor/tests/test_api.py +++ b/lms/djangoapps/instructor/tests/test_api.py @@ -1026,7 +1026,7 @@ class TestInstructorAPIBulkAccountCreationAndEnrollment(SharedModuleStoreTestCas # Remove white label course price self.white_label_course_mode.min_price = 0 self.white_label_course_mode.suggested_prices = '' - self.white_label_course_mode.save() # pylint: disable=no-member + self.white_label_course_mode.save() # Login Audit Course instructor self.client.login(username=self.white_label_course_instructor.username, password='test') @@ -2258,7 +2258,7 @@ class TestInstructorAPILevelsAccess(SharedModuleStoreTestCase, LoginEnrollmentTe def test_modify_access_with_inactive_user(self): self.other_user.is_active = False - self.other_user.save() # pylint: disable=no-member + self.other_user.save() url = reverse('modify_access', kwargs={'course_id': text_type(self.course.id)}) response = self.client.post(url, { 'unique_student_identifier': self.other_user.username, diff --git a/lms/djangoapps/instructor/tests/test_certificates.py b/lms/djangoapps/instructor/tests/test_certificates.py index 72f02245f0..a508103525 100644 --- a/lms/djangoapps/instructor/tests/test_certificates.py +++ b/lms/djangoapps/instructor/tests/test_certificates.py @@ -131,7 +131,7 @@ class CertificatesInstructorDashTest(SharedModuleStoreTestCase): """ self.course.cert_html_view_enabled = True self.course.save() - self.store.update_item(self.course, self.global_staff.id) # pylint: disable=no-member + self.store.update_item(self.course, self.global_staff.id) self.client.login(username=self.global_staff.username, password="test") response = self.client.get(self.url) self.assertContains(response, 'Enable Student-Generated Certificates') @@ -147,7 +147,7 @@ class CertificatesInstructorDashTest(SharedModuleStoreTestCase): """ self.course.cert_html_view_enabled = True self.course.save() - self.store.update_item(self.course, self.global_staff.id) # pylint: disable=no-member + self.store.update_item(self.course, self.global_staff.id) self.client.login(username=self.global_staff.username, password="test") response = self.client.get(self.url) self.assertContains(response, 'Enable Student-Generated Certificates') @@ -544,7 +544,7 @@ class CertificateExceptionViewInstructorApiTest(SharedModuleStoreTestCase): # Assert Certificate Exception Updated data self.assertEqual(certificate_exception['user_email'], self.user.email) self.assertEqual(certificate_exception['user_name'], self.user.username) - self.assertEqual(certificate_exception['user_id'], self.user.id) # pylint: disable=no-member + self.assertEqual(certificate_exception['user_id'], self.user.id) def test_certificate_exception_invalid_username_error(self): """ @@ -639,7 +639,7 @@ class CertificateExceptionViewInstructorApiTest(SharedModuleStoreTestCase): # Assert Certificate Exception Updated data self.assertEqual(certificate_exception['user_email'], self.user.email) self.assertEqual(certificate_exception['user_name'], self.user.username) - self.assertEqual(certificate_exception['user_id'], self.user.id) # pylint: disable=no-member + self.assertEqual(certificate_exception['user_id'], self.user.id) course2 = CourseFactory.create() url_course2 = reverse( @@ -660,7 +660,7 @@ class CertificateExceptionViewInstructorApiTest(SharedModuleStoreTestCase): # Assert Certificate Exception Updated data self.assertEqual(certificate_exception['user_email'], self.user.email) self.assertEqual(certificate_exception['user_name'], self.user.username) - self.assertEqual(certificate_exception['user_id'], self.user.id) # pylint: disable=no-member + self.assertEqual(certificate_exception['user_id'], self.user.id) def test_certificate_exception_user_not_enrolled_error(self): """ diff --git a/lms/djangoapps/instructor/tests/test_enrollment.py b/lms/djangoapps/instructor/tests/test_enrollment.py index 542da1e55b..818f8fe339 100644 --- a/lms/djangoapps/instructor/tests/test_enrollment.py +++ b/lms/djangoapps/instructor/tests/test_enrollment.py @@ -313,7 +313,6 @@ class TestInstructorEnrollmentStudentModule(SharedModuleStoreTestCase): org='course', run='id', ) - # pylint: disable=no-member cls.course_key = cls.course.location.course_key with cls.store.bulk_operations(cls.course.id, emit_signals=False): cls.parent = ItemFactory( diff --git a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py index 5d2e62d137..98bd965cc1 100644 --- a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py +++ b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py @@ -406,7 +406,7 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase, XssT response = self.client.get(url) self.assertEqual(response.status_code, 200) # Max number of student per page is one. Patched setting MAX_STUDENTS_PER_PAGE_GRADE_BOOK = 1 - self.assertEqual(len(response.mako_context['students']), 1) # pylint: disable=no-member + self.assertEqual(len(response.mako_context['students']), 1) def test_open_response_assessment_page(self): """ diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index c649ead2b7..4bd40fbee2 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -226,7 +226,7 @@ def require_level(level): raise ValueError("unrecognized level '{}'".format(level)) def decorator(func): # pylint: disable=missing-docstring - def wrapped(*args, **kwargs): # pylint: disable=missing-docstring + def wrapped(*args, **kwargs): request = args[0] course = get_course_by_id(CourseKey.from_string(kwargs['course_id'])) @@ -1826,7 +1826,7 @@ def spent_registration_codes(request, course_id): company_name = request.POST['spent_company_name'] if company_name: - spent_codes_list = spent_codes_list.filter(invoice_item__invoice__company_name=company_name) # pylint: disable=maybe-no-member + spent_codes_list = spent_codes_list.filter(invoice_item__invoice__company_name=company_name) csv_type = 'spent' return registration_codes_csv("Spent_Registration_Codes.csv", spent_codes_list, csv_type) @@ -1989,7 +1989,7 @@ def reset_student_attempts(request, course_id): @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_level('staff') @common_exceptions_400 -def reset_student_attempts_for_entrance_exam(request, course_id): # pylint: disable=invalid-name +def reset_student_attempts_for_entrance_exam(request, course_id): """ Resets a students attempts counter or starts a task to reset all students @@ -2340,7 +2340,7 @@ def list_instructor_tasks(request, course_id): @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_level('staff') -def list_entrance_exam_instructor_tasks(request, course_id): # pylint: disable=invalid-name +def list_entrance_exam_instructor_tasks(request, course_id): """ List entrance exam related instructor tasks. @@ -2878,7 +2878,7 @@ def enable_certificate_generation(request, course_id=None): @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_level('staff') @require_POST -def mark_student_can_skip_entrance_exam(request, course_id): # pylint: disable=invalid-name +def mark_student_can_skip_entrance_exam(request, course_id): """ Mark a student to skip entrance exam. Takes `unique_student_identifier` as required POST parameter. @@ -3184,7 +3184,7 @@ def generate_certificate_exceptions(request, course_id, generate_for=None): @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_global_staff @require_POST -def generate_bulk_certificate_exceptions(request, course_id): # pylint: disable=invalid-name +def generate_bulk_certificate_exceptions(request, course_id): """ Add Students to certificate white list from the uploaded csv file. :return response in dict format. diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 65bfdb7b06..23ef4c32d8 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -207,11 +207,11 @@ def instructor_dashboard_2(request, course_id): disable_buttons = not _is_small_course(course_key) certificate_white_list = CertificateWhitelist.get_certificate_white_list(course_key) - generate_certificate_exceptions_url = reverse( # pylint: disable=invalid-name + generate_certificate_exceptions_url = reverse( 'generate_certificate_exceptions', kwargs={'course_id': unicode(course_key), 'generate_for': ''} ) - generate_bulk_certificate_exceptions_url = reverse( # pylint: disable=invalid-name + generate_bulk_certificate_exceptions_url = reverse( 'generate_bulk_certificate_exceptions', kwargs={'course_id': unicode(course_key)} ) @@ -220,7 +220,7 @@ def instructor_dashboard_2(request, course_id): kwargs={'course_id': unicode(course_key)} ) - certificate_invalidation_view_url = reverse( # pylint: disable=invalid-name + certificate_invalidation_view_url = reverse( 'certificate_invalidation_view', kwargs={'course_id': unicode(course_key)} ) diff --git a/lms/djangoapps/shoppingcart/exceptions.py b/lms/djangoapps/shoppingcart/exceptions.py index a93c89bcec..1fbddab6f6 100644 --- a/lms/djangoapps/shoppingcart/exceptions.py +++ b/lms/djangoapps/shoppingcart/exceptions.py @@ -1,8 +1,6 @@ """ Exceptions for the shoppingcart app """ -# (Exception Class Names are sort of self-explanatory, so skipping docstring requirement) -# pylint: disable=missing-docstring class PaymentException(Exception): diff --git a/lms/djangoapps/shoppingcart/models.py b/lms/djangoapps/shoppingcart/models.py index 9f41593787..5473e4c9f8 100644 --- a/lms/djangoapps/shoppingcart/models.py +++ b/lms/djangoapps/shoppingcart/models.py @@ -352,7 +352,7 @@ class Order(models.Model): """ send confirmation e-mail """ - recipient_list = [(self.user.username, self.user.email, 'user')] # pylint: disable=no-member + recipient_list = [(self.user.username, self.user.email, 'user')] if self.company_contact_email: recipient_list.append((self.company_contact_name, self.company_contact_email, 'company_contact')) joined_course_names = "" @@ -443,7 +443,7 @@ class Order(models.Model): """ if self.status == 'purchased': log.error( - u"`purchase` method called on order {}, but order is already purchased.".format(self.id) # pylint: disable=no-member + u"`purchase` method called on order {}, but order is already purchased.".format(self.id) ) return self.status = 'purchased' @@ -1528,7 +1528,7 @@ class PaidCourseRegistration(OrderItem): @classmethod @transaction.atomic def add_to_order(cls, order, course_id, mode_slug=CourseMode.DEFAULT_SHOPPINGCART_MODE_SLUG, - cost=None, currency=None): # pylint: disable=arguments-differ + cost=None, currency=None): """ A standardized way to create these objects, with sensible defaults filled in. Will update the cost if called on an order that already carries the course. @@ -1715,7 +1715,7 @@ class CourseRegCodeItem(OrderItem): @classmethod @transaction.atomic def add_to_order(cls, order, course_id, qty, mode_slug=CourseMode.DEFAULT_SHOPPINGCART_MODE_SLUG, - cost=None, currency=None): # pylint: disable=arguments-differ + cost=None, currency=None): """ A standardized way to create these objects, with sensible defaults filled in. Will update the cost if called on an order that already carries the course. @@ -1838,7 +1838,6 @@ class CourseRegCodeItemAnnotation(models.Model): annotation = models.TextField(null=True) def __unicode__(self): - # pylint: disable=no-member return u"{} : {}".format(text_type(self.course_id), self.annotation) @@ -1856,7 +1855,6 @@ class PaidCourseRegistrationAnnotation(models.Model): annotation = models.TextField(null=True) def __unicode__(self): - # pylint: disable=no-member return u"{} : {}".format(text_type(self.course_id), self.annotation) diff --git a/lms/djangoapps/shoppingcart/tests/test_models.py b/lms/djangoapps/shoppingcart/tests/test_models.py index b4028033c7..ccc51f8051 100644 --- a/lms/djangoapps/shoppingcart/tests/test_models.py +++ b/lms/djangoapps/shoppingcart/tests/test_models.py @@ -270,7 +270,7 @@ class OrderTest(ModuleStoreTestCase): self.assertIn(item.additional_instruction_text(), mail.outbox[0].body) # Verify Google Analytics event fired for purchase - self.mock_tracker.track.assert_called_once_with( # pylint: disable=maybe-no-member + self.mock_tracker.track.assert_called_once_with( self.user.id, 'Completed Order', { @@ -870,7 +870,7 @@ class CertificateItemTest(ModuleStoreTestCase): """ Assert that we fired a refund event. """ - self.mock_analytics_tracker.track.assert_called_with( # pylint: disable=maybe-no-member + self.mock_analytics_tracker.track.assert_called_with( self.user.id, 'Refunded Order', { diff --git a/lms/djangoapps/shoppingcart/tests/test_views.py b/lms/djangoapps/shoppingcart/tests/test_views.py index e60e573e13..dd39308e6c 100644 --- a/lms/djangoapps/shoppingcart/tests/test_views.py +++ b/lms/djangoapps/shoppingcart/tests/test_views.py @@ -216,7 +216,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): resp = self.client.get(billing_url) self.assertEqual(resp.status_code, 200) - ((template, context), _) = render_mock.call_args # pylint: disable=redefined-outer-name + ((template, context), _) = render_mock.call_args # pylint: disable=unpacking-non-sequence self.assertEqual(template, 'shoppingcart/billing_details.html') # check for the default currency in the context self.assertEqual(context['currency'], 'usd') @@ -244,7 +244,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): resp = self.client.get(billing_url) self.assertEqual(resp.status_code, 200) - ((template, context), __) = render_mock.call_args # pylint: disable=redefined-outer-name + ((template, context), __) = render_mock.call_args # pylint: disable=unpacking-non-sequence self.assertEqual(template, 'shoppingcart/billing_details.html') # check for the override currency settings in the context @@ -804,7 +804,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): resp = self.client.get(reverse('shoppingcart.views.show_cart', args=[])) self.assertEqual(resp.status_code, 200) - ((purchase_form_arg_cart,), _) = form_mock.call_args # pylint: disable=redefined-outer-name + ((purchase_form_arg_cart,), _) = form_mock.call_args # pylint: disable=unpacking-non-sequence purchase_form_arg_cart_items = purchase_form_arg_cart.orderitem_set.all().select_subclasses() self.assertIn(reg_item, purchase_form_arg_cart_items) self.assertIn(cert_item, purchase_form_arg_cart_items) @@ -828,7 +828,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): resp = self.client.get(reverse('shoppingcart.views.show_cart', args=[])) self.assertEqual(resp.status_code, 200) - ((purchase_form_arg_cart,), _) = form_mock.call_args # pylint: disable=redefined-outer-name + ((purchase_form_arg_cart,), _) = form_mock.call_args # pylint: disable=unpacking-non-sequence purchase_form_arg_cart_items = purchase_form_arg_cart.orderitem_set.all().select_subclasses() self.assertIn(reg_item, purchase_form_arg_cart_items) @@ -1140,7 +1140,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): resp = self.client.get(reverse('shoppingcart.views.show_receipt', args=[self.cart.id])) self.assertEqual(resp.status_code, 200) - ((template, context), _) = render_mock.call_args # pylint: disable=redefined-outer-name + ((template, context), _) = render_mock.call_args # pylint: disable=unpacking-non-sequence self.assertEqual(template, 'shoppingcart/receipt.html') self.assertEqual(context['order'], self.cart) self.assertEqual(context['order'].total_cost, self.testing_cost) @@ -1185,7 +1185,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): self.assertIn('FirstNameTesting123', resp.content) self.assertIn('80.00', resp.content) - ((template, context), _) = render_mock.call_args # pylint: disable=redefined-outer-name + ((template, context), _) = render_mock.call_args # pylint: disable=unpacking-non-sequence self.assertEqual(template, 'shoppingcart/receipt.html') self.assertEqual(context['order'], self.cart) self.assertIn(reg_item, context['shoppingcart_items'][0]) @@ -1206,7 +1206,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): resp = self.client.get(reverse('shoppingcart.views.show_receipt', args=[self.cart.id])) self.assertEqual(resp.status_code, 200) - ((template, context), _) = render_mock.call_args # pylint: disable=redefined-outer-name + ((template, context), _) = render_mock.call_args # pylint: disable=unpacking-non-sequence self.assertEqual(template, 'shoppingcart/receipt.html') self.assertIn(reg_item, context['shoppingcart_items'][0]) self.assertIn(cert_item, context['shoppingcart_items'][1]) @@ -1255,7 +1255,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): # fetch the newly generated registration codes course_registration_codes = CourseRegistrationCode.objects.filter(order=self.cart) - ((template, context), _) = render_mock.call_args # pylint: disable=redefined-outer-name + ((template, context), _) = render_mock.call_args # pylint: disable=unpacking-non-sequence self.assertEqual(template, 'shoppingcart/receipt.html') self.assertEqual(context['order'], self.cart) self.assertIn(reg_item, context['shoppingcart_items'][0]) @@ -1287,7 +1287,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): # has been expired or not resp = self.client.get(reverse('shoppingcart.views.show_receipt', args=[self.cart.id])) self.assertEqual(resp.status_code, 200) - ((template, context), _) = render_mock.call_args # pylint: disable=redefined-outer-name + ((template, context), _) = render_mock.call_args # pylint: disable=unpacking-non-sequence self.assertEqual(template, 'shoppingcart/receipt.html') # now check for all the registration codes in the receipt # and one of code should be used at this point @@ -1307,7 +1307,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): self.login_user() - self.mock_tracker.emit.reset_mock() # pylint: disable=maybe-no-member + self.mock_tracker.emit.reset_mock() resp = self.client.get(reverse('shoppingcart.views.show_receipt', args=[self.cart.id])) self.assertEqual(resp.status_code, 200) @@ -1431,7 +1431,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): self.client.post(url, resp_params, follow=True) self.assertFalse(self.client.session.get('attempting_upgrade')) - self.mock_tracker.emit.assert_any_call( # pylint: disable=maybe-no-member + self.mock_tracker.emit.assert_any_call( 'edx.course.enrollment.upgrade.succeeded', { 'user_id': self.user.id, diff --git a/lms/djangoapps/support/decorators.py b/lms/djangoapps/support/decorators.py index b7d0fc2968..9b56d2a39b 100644 --- a/lms/djangoapps/support/decorators.py +++ b/lms/djangoapps/support/decorators.py @@ -14,7 +14,7 @@ def require_support_permission(func): View decorator that requires the user to have permission to use the support UI. """ @wraps(func) - def inner(request, *args, **kwargs): # pylint: disable=missing-docstring + def inner(request, *args, **kwargs): if has_access(request.user, "support", "global"): return func(request, *args, **kwargs) else: diff --git a/lms/djangoapps/support/tests/test_refund.py b/lms/djangoapps/support/tests/test_refund.py index d7a4abac91..5446d3b6a9 100644 --- a/lms/djangoapps/support/tests/test_refund.py +++ b/lms/djangoapps/support/tests/test_refund.py @@ -122,7 +122,7 @@ class RefundTests(ModuleStoreTestCase): pars['confirmed'] = 'true' response = self.client.post('/support/refund/', pars) self.assertTrue(response.status_code, 302) - response = self.client.get(response.get('location')) # pylint: disable=maybe-no-member + response = self.client.get(response.get('location')) self.assertContains(response, "Unenrolled %s from" % self.student) self.assertContains(response, "Refunded 1.00 for order id") diff --git a/lms/djangoapps/support/tests/test_views.py b/lms/djangoapps/support/tests/test_views.py index e8194e4976..271e83876a 100644 --- a/lms/djangoapps/support/tests/test_views.py +++ b/lms/djangoapps/support/tests/test_views.py @@ -216,15 +216,15 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase CourseMode.AUDIT, CourseMode.PROFESSIONAL, CourseMode.CREDIT_MODE, CourseMode.NO_ID_PROFESSIONAL_MODE, CourseMode.VERIFIED, CourseMode.HONOR ): - CourseModeFactory.create(mode_slug=mode, course_id=self.course.id) # pylint: disable=no-member + CourseModeFactory.create(mode_slug=mode, course_id=self.course.id) self.verification_deadline = VerificationDeadline( - course_key=self.course.id, # pylint: disable=no-member + course_key=self.course.id, deadline=datetime.now(UTC) + timedelta(days=365) ) self.verification_deadline.save() - CourseEnrollmentFactory.create(mode=CourseMode.AUDIT, user=self.student, course_id=self.course.id) # pylint: disable=no-member + CourseEnrollmentFactory.create(mode=CourseMode.AUDIT, user=self.student, course_id=self.course.id) self.url = reverse('support:enrollment_list', kwargs={'username_or_email': self.student.username}) @@ -232,7 +232,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase """ Assert that the student's enrollment has the correct mode. """ - enrollment = CourseEnrollment.get_enrollment(self.student, self.course.id) # pylint: disable=no-member + enrollment = CourseEnrollment.get_enrollment(self.student, self.course.id) self.assertEqual(enrollment.mode, mode) @ddt.data('username', 'email') @@ -249,7 +249,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase 'mode': CourseMode.AUDIT, 'manual_enrollment': {}, 'user': self.student.username, - 'course_id': unicode(self.course.id), # pylint: disable=no-member + 'course_id': unicode(self.course.id), 'is_active': True, 'verified_upgrade_deadline': None, }, data[0]) @@ -265,7 +265,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase self.student.email, ENROLLED_TO_ENROLLED, 'Financial Assistance', - CourseEnrollment.objects.get(course_id=self.course.id, user=self.student) # pylint: disable=no-member + CourseEnrollment.objects.get(course_id=self.course.id, user=self.student) ) response = self.client.get(self.url) self.assertEqual(response.status_code, 200) @@ -283,7 +283,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase kwargs={'username_or_email': getattr(self.student, search_string_type)} ) response = self.client.post(url, data={ - 'course_id': unicode(self.course.id), # pylint: disable=no-member + 'course_id': unicode(self.course.id), 'old_mode': CourseMode.AUDIT, 'new_mode': CourseMode.VERIFIED, 'reason': 'Financial Assistance' @@ -319,7 +319,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase # `self` isn't available from within the DDT declaration, so # assign the course ID here if 'course_id' in data and data['course_id'] is None: - data['course_id'] = unicode(self.course.id) # pylint: disable=no-member + data['course_id'] = unicode(self.course.id) response = self.client.post(self.url, data) self.assertEqual(response.status_code, 400) self.assertIsNotNone(re.match(error_message, response.content)) @@ -365,7 +365,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase def _assert_generated_modes(self, response): """Dry method to generate course modes dict and test with response data.""" - modes = CourseMode.modes_for_course(self.course.id, include_expired=True) # pylint: disable=no-member + modes = CourseMode.modes_for_course(self.course.id, include_expired=True) modes_data = [] for mode in modes: expiry = mode.expiration_datetime.strftime('%Y-%m-%dT%H:%M:%SZ') if mode.expiration_datetime else None @@ -404,7 +404,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase kwargs={'username_or_email': getattr(self.student, search_string_type)} ) response = self.client.post(url, data={ - 'course_id': unicode(self.course.id), # pylint: disable=no-member + 'course_id': unicode(self.course.id), 'old_mode': CourseMode.AUDIT, 'new_mode': new_mode, 'reason': 'Financial Assistance' @@ -424,7 +424,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase # change verified mode expiry. verified_mode = CourseMode.objects.get( - course_id=self.course.id, # pylint: disable=no-member + course_id=self.course.id, mode_slug=CourseMode.VERIFIED ) verified_mode.expiration_datetime = datetime(year=1970, month=1, day=9, tzinfo=UTC) diff --git a/lms/envs/acceptance.py b/lms/envs/acceptance.py index fbb43c3df0..15f050f955 100644 --- a/lms/envs/acceptance.py +++ b/lms/envs/acceptance.py @@ -172,7 +172,7 @@ SELENIUM_GRID = { ##################################################################### # See if the developer has any local overrides. try: - from .private import * # pylint: disable=import-error + from .private import * except ImportError: pass diff --git a/lms/envs/bok_choy.py b/lms/envs/bok_choy.py index f1248d8081..660e77b74c 100644 --- a/lms/envs/bok_choy.py +++ b/lms/envs/bok_choy.py @@ -249,6 +249,6 @@ COMPLETION_BY_VIEWING_DELAY_MS = 1000 ##################################################################### # Lastly, see if the developer has any local overrides. try: - from .private import * # pylint: disable=import-error + from .private import * # pylint: disable=wildcard-import except ImportError: pass diff --git a/lms/envs/common.py b/lms/envs/common.py index e44c1e881e..7721009955 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -20,9 +20,8 @@ Longer TODO: multiple sites, but we do need a way to map their data assets. """ -# We intentionally define lots of variables that aren't used, and -# want to import all variables from base settings files -# pylint: disable=wildcard-import, unused-import, unused-wildcard-import +# We intentionally define lots of variables that aren't used +# pylint: disable=unused-import # Pylint gets confused by path.py instances, which report themselves as class # objects. As a result, pylint applies the wrong regex in validating names, diff --git a/lms/envs/devstack_optimized.py b/lms/envs/devstack_optimized.py index 054e9c9e5a..c13f6320bd 100644 --- a/lms/envs/devstack_optimized.py +++ b/lms/envs/devstack_optimized.py @@ -25,7 +25,7 @@ import os if 'BOK_CHOY_HOSTNAME' in os.environ: from .devstack_docker import * # pylint: disable=wildcard-import, unused-wildcard-import else: - from .devstack import * # pylint: disable=wildcard-import, unused-wildcard-import + from .devstack import * # pylint: disable=wildcard-import TEST_ROOT = REPO_ROOT / "test_root" diff --git a/lms/envs/test.py b/lms/envs/test.py index 3db41d9310..7266121d2a 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -13,11 +13,6 @@ sessions. Assumes structure: # want to import all variables from base settings files # pylint: disable=wildcard-import, unused-wildcard-import -# Pylint gets confused by path.py instances, which report themselves as class -# objects. As a result, pylint applies the wrong regex in validating names, -# and throws spurious errors. Therefore, we disable invalid-name checking. -# pylint: disable=invalid-name - from .common import * import os from path import Path as path diff --git a/scripts/thresholds.sh b/scripts/thresholds.sh index c2b8de1197..9648693015 100755 --- a/scripts/thresholds.sh +++ b/scripts/thresholds.sh @@ -2,6 +2,6 @@ set -e export LOWER_PYLINT_THRESHOLD=1000 -export UPPER_PYLINT_THRESHOLD=3310 +export UPPER_PYLINT_THRESHOLD=3125 export ESLINT_THRESHOLD=5590 export STYLELINT_THRESHOLD=973