From 68902a2f3f944072e5a89e094c1149b0bcee31bf Mon Sep 17 00:00:00 2001 From: Jeremy Bowman Date: Wed, 15 Aug 2018 15:43:10 -0400 Subject: [PATCH] TE-2689 Remove useless pylint suppressions part 3 --- cms/djangoapps/cms_user_tasks/tests.py | 4 ++-- cms/djangoapps/contentstore/courseware_index.py | 2 +- .../management/commands/tests/test_migrate_to_split.py | 2 +- cms/djangoapps/contentstore/tasks.py | 6 +++--- .../contentstore/tests/test_course_listing.py | 2 +- cms/djangoapps/contentstore/tests/test_tasks.py | 2 +- cms/djangoapps/contentstore/tests/test_utils.py | 4 ++-- cms/djangoapps/contentstore/utils.py | 1 - cms/djangoapps/contentstore/views/component.py | 2 +- cms/djangoapps/contentstore/views/course.py | 5 +---- cms/djangoapps/contentstore/views/entrance_exam.py | 1 - cms/djangoapps/contentstore/views/helpers.py | 2 +- cms/djangoapps/contentstore/views/import_export.py | 4 ++-- cms/djangoapps/contentstore/views/item.py | 6 +++--- .../contentstore/views/tests/test_import_export.py | 4 ++-- cms/djangoapps/contentstore/views/tests/test_item.py | 2 +- cms/djangoapps/contentstore/views/videos.py | 2 +- cms/djangoapps/maintenance/tests.py | 4 ++-- cms/djangoapps/models/settings/course_metadata.py | 4 ++-- cms/envs/acceptance.py | 2 +- cms/envs/aws.py | 5 ----- cms/envs/bok_choy.py | 2 +- cms/envs/devstack_optimized.py | 2 +- cms/envs/test.py | 5 ----- cms/lib/xblock/tagging/test.py | 2 +- lms/djangoapps/discussion_api/api.py | 4 ++-- lms/djangoapps/discussion_api/permissions.py | 2 +- lms/djangoapps/grades/tests/integration/test_access.py | 1 - .../grades/tests/integration/test_problems.py | 1 - .../learner_dashboard/tests/test_programs.py | 6 +++--- lms/djangoapps/lti_provider/apps.py | 2 +- lms/djangoapps/mobile_api/context_processor.py | 2 +- lms/djangoapps/mobile_api/tests/test_milestones.py | 10 +++++----- lms/djangoapps/mobile_api/testutils.py | 6 ++---- lms/djangoapps/mobile_api/users/tests.py | 1 - lms/djangoapps/mobile_api/video_outlines/tests.py | 4 ++-- lms/djangoapps/notes/models.py | 1 - lms/djangoapps/oauth2_handler/tests.py | 2 +- lms/djangoapps/student_account/test/test_views.py | 4 ++-- lms/djangoapps/student_account/views.py | 8 ++++---- lms/djangoapps/teams/search_indexes.py | 2 +- lms/djangoapps/teams/tests/test_models.py | 5 ++--- lms/djangoapps/teams/views.py | 2 +- lms/djangoapps/verify_student/exceptions.py | 2 -- lms/djangoapps/verify_student/tests/test_views.py | 2 +- lms/djangoapps/verify_student/views.py | 8 ++++---- scripts/thresholds.sh | 2 +- 47 files changed, 65 insertions(+), 89 deletions(-) diff --git a/cms/djangoapps/cms_user_tasks/tests.py b/cms/djangoapps/cms_user_tasks/tests.py index 0ec1fb1d41..da899a6fc5 100644 --- a/cms/djangoapps/cms_user_tasks/tests.py +++ b/cms/djangoapps/cms_user_tasks/tests.py @@ -53,14 +53,14 @@ def _context(response): """ Get a context dictionary for a serializer appropriate for the given response. """ - return {'request': response.wsgi_request} # pylint: disable=no-member + return {'request': response.wsgi_request} def _data(response): """ Get the serialized data dictionary from the given REST API test response. """ - return response.data # pylint: disable=no-member + return response.data @override_settings(BROKER_URL='memory://localhost/') diff --git a/cms/djangoapps/contentstore/courseware_index.py b/cms/djangoapps/contentstore/courseware_index.py index f5f67fc7cb..d08eabeda3 100644 --- a/cms/djangoapps/contentstore/courseware_index.py +++ b/cms/djangoapps/contentstore/courseware_index.py @@ -631,7 +631,7 @@ class CourseAboutSearchIndexer(object): # Broad exception handler to protect around and report problems with indexing try: searcher.index(cls.DISCOVERY_DOCUMENT_TYPE, [course_info]) - except: # pylint: disable=bare-except + except: log.exception( "Course discovery indexing error encountered, course discovery index may be out of date %s", course_id, 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 2d68db80fb..96373b6fd4 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 @@ -50,7 +50,7 @@ class TestArgParsing(TestCase): call_command("migrate_to_split", "org/course/name", "fake@example.com") -# pylint: disable=no-member, protected-access +# pylint: disable=protected-access class TestMigrateToSplit(ModuleStoreTestCase): """ Unit tests for migrating a course from old mongo to split mongo diff --git a/cms/djangoapps/contentstore/tasks.py b/cms/djangoapps/contentstore/tasks.py index 2cef65ca49..4670ac559c 100644 --- a/cms/djangoapps/contentstore/tasks.py +++ b/cms/djangoapps/contentstore/tasks.py @@ -687,7 +687,7 @@ def import_olx(self, user_id, course_key_string, archive_path, archive_name, lan return temp_filepath = course_dir / get_valid_filename(archive_name) - if not course_dir.isdir(): # pylint: disable=no-value-for-parameter + if not course_dir.isdir(): os.mkdir(course_dir) LOGGER.debug(u'importing course to {0}'.format(temp_filepath)) @@ -726,7 +726,7 @@ def import_olx(self, user_id, course_key_string, archive_path, archive_name, lan ) # Send errors to client with stage at which error occurred. except Exception as exception: # pylint: disable=broad-except - if course_dir.isdir(): # pylint: disable=no-value-for-parameter + if course_dir.isdir(): shutil.rmtree(course_dir) LOGGER.info(u'Course import %s: Temp data cleared', courselike_key) @@ -805,7 +805,7 @@ def import_olx(self, user_id, course_key_string, archive_path, archive_name, lan LOGGER.exception(u'error importing course', exc_info=True) self.status.fail(text_type(exception)) finally: - if course_dir.isdir(): # pylint: disable=no-value-for-parameter + if course_dir.isdir(): shutil.rmtree(course_dir) LOGGER.info(u'Course import %s: Temp data cleared', courselike_key) diff --git a/cms/djangoapps/contentstore/tests/test_course_listing.py b/cms/djangoapps/contentstore/tests/test_course_listing.py index 60f18dcd6d..48b12e28ee 100644 --- a/cms/djangoapps/contentstore/tests/test_course_listing.py +++ b/cms/djangoapps/contentstore/tests/test_course_listing.py @@ -302,7 +302,7 @@ class TestCourseListing(ModuleStoreTestCase): course_location = self.store.make_course_key('testOrg', 'doomedCourse', 'RunBabyRun') self._create_course_with_access_groups(course_location, self.user, store) - self.store.delete_course(course_location, self.user.id) # pylint: disable=no-member + self.store.delete_course(course_location, self.user.id) courses_list, __ = _accessible_courses_list_from_groups(self.request) self.assertEqual(len(courses_list), 1, courses_list) diff --git a/cms/djangoapps/contentstore/tests/test_tasks.py b/cms/djangoapps/contentstore/tests/test_tasks.py index 9b732b28c7..e125886037 100644 --- a/cms/djangoapps/contentstore/tests/test_tasks.py +++ b/cms/djangoapps/contentstore/tests/test_tasks.py @@ -104,7 +104,7 @@ class ExportLibraryTestCase(LibraryTestCase): Verify that a routine library export task succeeds """ key = str(self.lib_key) - result = export_olx.delay(self.user.id, key, u'en') # pylint: disable=no-member + result = export_olx.delay(self.user.id, key, u'en') status = UserTaskStatus.objects.get(task_id=result.id) self.assertEqual(status.state, UserTaskStatus.SUCCEEDED) artifacts = UserTaskArtifact.objects.filter(status=status) diff --git a/cms/djangoapps/contentstore/tests/test_utils.py b/cms/djangoapps/contentstore/tests/test_utils.py index 0d5d640c78..ef769339ad 100644 --- a/cms/djangoapps/contentstore/tests/test_utils.py +++ b/cms/djangoapps/contentstore/tests/test_utils.py @@ -387,7 +387,7 @@ class GroupVisibilityTest(CourseTestCase): def test_no_visibility_set(self): """ Tests when group_access has not been set on anything. """ - def verify_all_components_visible_to_all(): # pylint: disable=invalid-name + def verify_all_components_visible_to_all(): """ Verifies when group_access has not been set on anything. """ for item in (self.sequential, self.vertical, self.html, self.problem): self.assertFalse(utils.has_children_visible_to_specific_partition_groups(item)) @@ -430,7 +430,7 @@ class GetUserPartitionInfoTest(ModuleStoreTestCase): """Create a dummy course. """ super(GetUserPartitionInfoTest, self).setUp() self.course = CourseFactory() - self.block = ItemFactory.create(category="problem", parent_location=self.course.location) # pylint: disable=no-member + self.block = ItemFactory.create(category="problem", parent_location=self.course.location) # Set up some default partitions self._set_partitions([ diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index e9f886605f..af2faecfb5 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -131,7 +131,6 @@ def get_lms_link_for_item(location, preview=False): ) -# pylint: disable=invalid-name def get_lms_link_for_certificate_web_view(user_id, course_key, mode): """ Returns the url to the certificate web view. diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index f65f281151..e9c036588f 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -294,7 +294,7 @@ def get_component_templates(courselike, library=False): templates_for_category.append( create_template_dict( - _(template['metadata'].get('display_name')), # pylint: disable=translation-of-non-string + _(template['metadata'].get('display_name')), category, support_level_with_template, template_id, diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 4b8df97645..baa01a1c35 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -6,7 +6,7 @@ import json import logging import random import re -import string # pylint: disable=deprecated-module +import string import django.utils import six @@ -221,7 +221,6 @@ def _dismiss_notification(request, course_action_state_id): # pylint: disable=u return JsonResponse({'success': True}) -# pylint: disable=unused-argument @login_required def course_handler(request, course_key_string=None): """ @@ -935,7 +934,6 @@ def rerun_course(user, source_course_key, org, number, run, fields, async=True): return destination_course_key -# pylint: disable=unused-argument @login_required @ensure_csrf_cookie @require_http_methods(["GET"]) @@ -968,7 +966,6 @@ def course_info_handler(request, course_key_string): return HttpResponseBadRequest("Only supports html requests") -# pylint: disable=unused-argument @login_required @ensure_csrf_cookie @require_http_methods(("GET", "POST", "PUT", "DELETE")) diff --git a/cms/djangoapps/contentstore/views/entrance_exam.py b/cms/djangoapps/contentstore/views/entrance_exam.py index 4b2d7aab07..e7cf12ee5a 100644 --- a/cms/djangoapps/contentstore/views/entrance_exam.py +++ b/cms/djangoapps/contentstore/views/entrance_exam.py @@ -27,7 +27,6 @@ __all__ = ['entrance_exam', ] log = logging.getLogger(__name__) -# pylint: disable=invalid-name def _get_default_entrance_exam_minimum_pct(): """ Helper method to return the default value from configuration diff --git a/cms/djangoapps/contentstore/views/helpers.py b/cms/djangoapps/contentstore/views/helpers.py index a9fa8be4af..ec8ad175ea 100644 --- a/cms/djangoapps/contentstore/views/helpers.py +++ b/cms/djangoapps/contentstore/views/helpers.py @@ -145,7 +145,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) # pylint: disable=translation-of-non-string + return _(component_class.display_name.default) else: return default_display_name diff --git a/cms/djangoapps/contentstore/views/import_export.py b/cms/djangoapps/contentstore/views/import_export.py index 4bee4b776d..735f666839 100644 --- a/cms/djangoapps/contentstore/views/import_export.py +++ b/cms/djangoapps/contentstore/views/import_export.py @@ -138,7 +138,7 @@ def _write_chunk(request, courselike_key): ) temp_filepath = course_dir / filename - if not course_dir.isdir(): # pylint: disable=no-value-for-parameter + if not course_dir.isdir(): os.mkdir(course_dir) logging.debug('importing course to {0}'.format(temp_filepath)) @@ -208,7 +208,7 @@ def _write_chunk(request, courselike_key): # Send errors to client with stage at which error occurred. except Exception as exception: # pylint: disable=broad-except _save_request_status(request, courselike_string, -1) - if course_dir.isdir(): # pylint: disable=no-value-for-parameter + if course_dir.isdir(): shutil.rmtree(course_dir) log.info("Course import %s: Temp data cleared", courselike_key) diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index 5baf93c53a..6d6c0ffee7 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -1052,7 +1052,7 @@ def _get_gating_info(course, xblock): if not hasattr(course, 'gating_prerequisites'): # Cache gating prerequisites on course module so that we are not # hitting the database for every xblock in the course - setattr(course, 'gating_prerequisites', gating_api.get_prerequisites(course.id)) # pylint: disable=literal-used-as-attribute + setattr(course, 'gating_prerequisites', gating_api.get_prerequisites(course.id)) info["is_prereq"] = gating_api.is_prerequisite(course.id, xblock.location) info["prereqs"] = [ p for p in course.gating_prerequisites if unicode(xblock.location) not in p['namespace'] @@ -1271,7 +1271,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F return xblock_info -def add_container_page_publishing_info(xblock, xblock_info): # pylint: disable=invalid-name +def add_container_page_publishing_info(xblock, xblock_info): """ Adds information about the xblock's publish state to the supplied xblock_info for the container page. @@ -1405,7 +1405,7 @@ def _create_xblock_ancestor_info(xblock, course_outline=False, include_child_inf def _create_xblock_child_info(xblock, course_outline, graders, include_children_predicate=NEVER, user=None, - course=None, is_concise=False): # pylint: disable=line-too-long + course=None, is_concise=False): """ Returns information about the children of an xblock, as well as about the primary category of xblock expected as children. diff --git a/cms/djangoapps/contentstore/views/tests/test_import_export.py b/cms/djangoapps/contentstore/views/tests/test_import_export.py index b789c21f90..4ba3a0ab77 100644 --- a/cms/djangoapps/contentstore/views/tests/test_import_export.py +++ b/cms/djangoapps/contentstore/views/tests/test_import_export.py @@ -836,7 +836,7 @@ class TestCourseExportImport(LibraryTestCase): ItemFactory.create( category="problem", parent_location=self.library.location, - user_id=self.user.id, # pylint: disable=no-member + user_id=self.user.id, publish_item=False, display_name='Test Problem', data="", @@ -927,7 +927,7 @@ class TestCourseExportImport(LibraryTestCase): # Now, import it back to dest_course. import_course_from_xml( self.store, - self.user.id, # pylint: disable=no-member + self.user.id, self.export_dir, ['exported_source_course'], static_content_store=contentstore(), diff --git a/cms/djangoapps/contentstore/views/tests/test_item.py b/cms/djangoapps/contentstore/views/tests/test_item.py index 9b979c94fd..fb9c550342 100644 --- a/cms/djangoapps/contentstore/views/tests/test_item.py +++ b/cms/djangoapps/contentstore/views/tests/test_item.py @@ -1364,7 +1364,7 @@ class TestDuplicateItemWithAsides(ItemTest, DuplicateHelper): key_store = DictKeyValueStore() field_data = KvsFieldData(key_store) - runtime = TestRuntime(services={'field-data': field_data}) # pylint: disable=abstract-class-instantiated + runtime = TestRuntime(services={'field-data': field_data}) def_id = runtime.id_generator.create_definition(block_type) usage_id = runtime.id_generator.create_usage(def_id) diff --git a/cms/djangoapps/contentstore/views/videos.py b/cms/djangoapps/contentstore/views/videos.py index 897af97ae7..102f699e00 100644 --- a/cms/djangoapps/contentstore/views/videos.py +++ b/cms/djangoapps/contentstore/views/videos.py @@ -145,7 +145,7 @@ class StatusDisplayStrings(object): @staticmethod def get(val_status): """Map a VAL status string to a localized display string""" - return _(StatusDisplayStrings._STATUS_MAP.get(val_status, StatusDisplayStrings._UNKNOWN)) # pylint: disable=translation-of-non-string + return _(StatusDisplayStrings._STATUS_MAP.get(val_status, StatusDisplayStrings._UNKNOWN)) @expect_json diff --git a/cms/djangoapps/maintenance/tests.py b/cms/djangoapps/maintenance/tests.py index 981f1b2c70..a8cf77817f 100644 --- a/cms/djangoapps/maintenance/tests.py +++ b/cms/djangoapps/maintenance/tests.py @@ -143,7 +143,7 @@ class TestForcePublish(MaintenanceViewTestCase): # Add some changes to course chapter = ItemFactory.create(category='chapter', parent_location=course.location) self.store.create_child( - self.user.id, # pylint: disable=no-member + self.user.id, chapter.location, 'html', block_id='html_component' @@ -204,7 +204,7 @@ class TestForcePublish(MaintenanceViewTestCase): # publish the course source_store = modulestore()._get_modulestore_for_courselike(course.id) # pylint: disable=protected-access - source_store.force_publish_course(course.id, self.user.id, commit=True) # pylint: disable=no-member + source_store.force_publish_course(course.id, self.user.id, commit=True) # now course is published, we should get `already published course` error. self.verify_error_message( diff --git a/cms/djangoapps/models/settings/course_metadata.py b/cms/djangoapps/models/settings/course_metadata.py index 22e2a9bae7..ff3fb46616 100644 --- a/cms/djangoapps/models/settings/course_metadata.py +++ b/cms/djangoapps/models/settings/course_metadata.py @@ -143,14 +143,14 @@ class CourseMetadata(object): if field.scope != Scope.settings: continue - field_help = _(field.help) # pylint: disable=translation-of-non-string + field_help = _(field.help) help_args = field.runtime_options.get('help_format_args') if help_args is not None: field_help = field_help.format(**help_args) result[field.name] = { 'value': field.read_json(descriptor), - 'display_name': _(field.display_name), # pylint: disable=translation-of-non-string + 'display_name': _(field.display_name), 'help': field_help, 'deprecated': field.runtime_options.get('deprecated', False) } diff --git a/cms/envs/acceptance.py b/cms/envs/acceptance.py index 766496f486..a37cf8d170 100644 --- a/cms/envs/acceptance.py +++ b/cms/envs/acceptance.py @@ -128,7 +128,7 @@ SELENIUM_GRID = { ##################################################################### # Lastly, 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/cms/envs/aws.py b/cms/envs/aws.py index dc5991d614..2f62502819 100644 --- a/cms/envs/aws.py +++ b/cms/envs/aws.py @@ -6,11 +6,6 @@ This is the default template for our main set of AWS servers. # 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 - import json from .common import * diff --git a/cms/envs/bok_choy.py b/cms/envs/bok_choy.py index a82d64360c..e7d7437b3b 100644 --- a/cms/envs/bok_choy.py +++ b/cms/envs/bok_choy.py @@ -162,6 +162,6 @@ VIDEO_TRANSCRIPTS_SETTINGS = dict( ##################################################################### # 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/cms/envs/devstack_optimized.py b/cms/envs/devstack_optimized.py index ff0a2c761d..8763669f3f 100644 --- a/cms/envs/devstack_optimized.py +++ b/cms/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/cms/envs/test.py b/cms/envs/test.py index ed891b320b..c7022d98db 100644 --- a/cms/envs/test.py +++ b/cms/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/cms/lib/xblock/tagging/test.py b/cms/lib/xblock/tagging/test.py index 173fa9b040..0341667977 100644 --- a/cms/lib/xblock/tagging/test.py +++ b/cms/lib/xblock/tagging/test.py @@ -123,7 +123,7 @@ class StructuredTagsAsideTestCase(ModuleStoreTestCase): usage_id="usage-id") key_store = DictKeyValueStore() field_data = KvsFieldData(key_store) - runtime = TestRuntime(services={'field-data': field_data}) # pylint: disable=abstract-class-instantiated + runtime = TestRuntime(services={'field-data': field_data}) xblock_aside = StructuredTagsAside(scope_ids=sids, runtime=runtime) available_tags = xblock_aside.get_available_tags() self.assertEquals(len(available_tags), 2, "StructuredTagsAside should contains two tag categories") diff --git a/lms/djangoapps/discussion_api/api.py b/lms/djangoapps/discussion_api/api.py index 6c26e9af6b..e1e83cda41 100644 --- a/lms/djangoapps/discussion_api/api.py +++ b/lms/djangoapps/discussion_api/api.py @@ -680,7 +680,7 @@ def _check_fields(allowed_fields, data, message): raise ValidationError(non_allowed_fields) -def _check_initializable_thread_fields(data, context): # pylint: disable=invalid-name +def _check_initializable_thread_fields(data, context): """ Checks if the given data contains a thread field that is not initializable by the requesting user @@ -701,7 +701,7 @@ def _check_initializable_thread_fields(data, context): # pylint: disable=invali ) -def _check_initializable_comment_fields(data, context): # pylint: disable=invalid-name +def _check_initializable_comment_fields(data, context): """ Checks if the given data contains a comment field that is not initializable by the requesting user diff --git a/lms/djangoapps/discussion_api/permissions.py b/lms/djangoapps/discussion_api/permissions.py index 7387c48cab..37f0d2f6d3 100644 --- a/lms/djangoapps/discussion_api/permissions.py +++ b/lms/djangoapps/discussion_api/permissions.py @@ -38,7 +38,7 @@ def get_initializable_thread_fields(context): return ret -def get_initializable_comment_fields(context): # pylint: disable=invalid-name +def get_initializable_comment_fields(context): """ Return the set of fields that the requester can initialize for a comment diff --git a/lms/djangoapps/grades/tests/integration/test_access.py b/lms/djangoapps/grades/tests/integration/test_access.py index 992d02aebc..33c6195bbd 100644 --- a/lms/djangoapps/grades/tests/integration/test_access.py +++ b/lms/djangoapps/grades/tests/integration/test_access.py @@ -1,7 +1,6 @@ """ Test grading with access changes. """ -# pylint: disable=protected-access from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory from courseware.tests.test_submitting_problems import ProblemSubmissionTestMixin diff --git a/lms/djangoapps/grades/tests/integration/test_problems.py b/lms/djangoapps/grades/tests/integration/test_problems.py index f3e81a95a0..61adec4dad 100644 --- a/lms/djangoapps/grades/tests/integration/test_problems.py +++ b/lms/djangoapps/grades/tests/integration/test_problems.py @@ -250,7 +250,6 @@ class TestWeightedProblems(SharedModuleStoreTestCase): Verifies the computed grades are as expected. """ with self.store.branch_setting(ModuleStoreEnum.Branch.draft_preferred): - # pylint: disable=no-member for problem in self.problems: problem.weight = weight self.store.update_item(problem, self.user.id) diff --git a/lms/djangoapps/learner_dashboard/tests/test_programs.py b/lms/djangoapps/learner_dashboard/tests/test_programs.py index 6057f66d84..a690f113df 100644 --- a/lms/djangoapps/learner_dashboard/tests/test_programs.py +++ b/lms/djangoapps/learner_dashboard/tests/test_programs.py @@ -47,7 +47,7 @@ class TestProgramListing(ProgramsApiConfigMixin, SharedModuleStoreTestCase): super(TestProgramListing, cls).setUpClass() cls.course = ModuleStoreCourseFactory() - course_run = CourseRunFactory(key=unicode(cls.course.id)) # pylint: disable=no-member + course_run = CourseRunFactory(key=unicode(cls.course.id)) course = CourseFactory(course_runs=[course_run]) cls.first_program = ProgramFactory(courses=[course]) @@ -137,7 +137,7 @@ class TestProgramListing(ProgramsApiConfigMixin, SharedModuleStoreTestCase): self.create_programs_config() mock_get_programs.return_value = self.data - CourseEnrollmentFactory(user=self.user, course_id=self.course.id) # pylint: disable=no-member + CourseEnrollmentFactory(user=self.user, course_id=self.course.id) response = self.client.get(self.url) actual = self.load_serialized_data(response, 'programsData') @@ -166,7 +166,7 @@ class TestProgramListing(ProgramsApiConfigMixin, SharedModuleStoreTestCase): self.create_programs_config() mock_get_programs.return_value = self.data - CourseEnrollmentFactory(user=self.user, course_id=self.course.id) # pylint: disable=no-member + CourseEnrollmentFactory(user=self.user, course_id=self.course.id) response = self.client.get(self.url) actual = self.load_serialized_data(response, 'programsData') diff --git a/lms/djangoapps/lti_provider/apps.py b/lms/djangoapps/lti_provider/apps.py index 8d271688af..931806b315 100644 --- a/lms/djangoapps/lti_provider/apps.py +++ b/lms/djangoapps/lti_provider/apps.py @@ -13,4 +13,4 @@ class LtiProviderConfig(AppConfig): def ready(self): # Import the tasks module to ensure that signal handlers are registered. - from . import signals # pylint: disable=unused-import + from . import signals # pylint: disable=unused-variable diff --git a/lms/djangoapps/mobile_api/context_processor.py b/lms/djangoapps/mobile_api/context_processor.py index 51de77f10c..32c5adf876 100644 --- a/lms/djangoapps/mobile_api/context_processor.py +++ b/lms/djangoapps/mobile_api/context_processor.py @@ -5,7 +5,7 @@ Django template context processors. from openedx.core.lib.mobile_utils import is_request_from_mobile_app -def is_from_mobile_app(request): # pylint: disable=unused-argument +def is_from_mobile_app(request): """ Configuration context for django templates. """ diff --git a/lms/djangoapps/mobile_api/tests/test_milestones.py b/lms/djangoapps/mobile_api/tests/test_milestones.py index 00e99fd865..e3a3db1dbd 100644 --- a/lms/djangoapps/mobile_api/tests/test_milestones.py +++ b/lms/djangoapps/mobile_api/tests/test_milestones.py @@ -22,7 +22,7 @@ class MobileAPIMilestonesMixin(object): """ shard = 4 - ALLOW_ACCESS_TO_MILESTONE_COURSE = False # pylint: disable=invalid-name + ALLOW_ACCESS_TO_MILESTONE_COURSE = False @patch.dict(settings.FEATURES, { 'ENABLE_PREREQUISITE_COURSES': True, @@ -85,21 +85,21 @@ class MobileAPIMilestonesMixin(object): with self.store.bulk_operations(self.course.id): self.course.entrance_exam_enabled = True - self.entrance_exam = ItemFactory.create( # pylint: disable=attribute-defined-outside-init + self.entrance_exam = ItemFactory.create( parent=self.course, category="chapter", display_name="Entrance Exam Chapter", is_entrance_exam=True, in_entrance_exam=True, ) - self.subsection_1 = ItemFactory.create( # pylint: disable=attribute-defined-outside-init + self.subsection_1 = ItemFactory.create( parent=self.entrance_exam, category='sequential', display_name="The Only Exam Sequential", graded=True, in_entrance_exam=True, ) - self.problem_1 = ItemFactory.create( # pylint: disable=attribute-defined-outside-init + self.problem_1 = ItemFactory.create( parent=self.subsection_1, category='problem', display_name="The Only Exam Problem", @@ -115,7 +115,7 @@ class MobileAPIMilestonesMixin(object): def _add_prerequisite_course(self): """ Helper method to set up the prerequisite course """ - self.prereq_course = CourseFactory.create() # pylint: disable=attribute-defined-outside-init + self.prereq_course = CourseFactory.create() add_prerequisite_course(self.course.id, self.prereq_course.id) def _pass_entrance_exam(self): diff --git a/lms/djangoapps/mobile_api/testutils.py b/lms/djangoapps/mobile_api/testutils.py index 1a19894316..1dd9cf1673 100644 --- a/lms/djangoapps/mobile_api/testutils.py +++ b/lms/djangoapps/mobile_api/testutils.py @@ -141,8 +141,8 @@ class MobileCourseAccessTestMixin(MobileAPIMilestonesMixin): Subclasses are expected to inherit from MobileAPITestCase. Subclasses can override verify_success, verify_failure, and init_course_access methods. """ - ALLOW_ACCESS_TO_UNRELEASED_COURSE = False # pylint: disable=invalid-name - ALLOW_ACCESS_TO_NON_VISIBLE_COURSE = False # pylint: disable=invalid-name + ALLOW_ACCESS_TO_UNRELEASED_COURSE = False + ALLOW_ACCESS_TO_NON_VISIBLE_COURSE = False def verify_success(self, response): """Base implementation of verifying a successful response.""" @@ -175,9 +175,7 @@ class MobileCourseAccessTestMixin(MobileAPIMilestonesMixin): @patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False, 'ENABLE_MKTG_SITE': True}) def test_unreleased_course(self): # ensure the course always starts in the future - # pylint: disable=attribute-defined-outside-init self.course = CourseFactory.create(mobile_available=True, static_asset_path="needed_for_split") - # pylint: disable=attribute-defined-outside-init self.course.start = timezone.now() + datetime.timedelta(days=365) self.init_course_access() self._verify_response(self.ALLOW_ACCESS_TO_UNRELEASED_COURSE, StartDateError(self.course.start)) diff --git a/lms/djangoapps/mobile_api/users/tests.py b/lms/djangoapps/mobile_api/users/tests.py index f19d00cf1a..87a4ed3da4 100644 --- a/lms/djangoapps/mobile_api/users/tests.py +++ b/lms/djangoapps/mobile_api/users/tests.py @@ -1,7 +1,6 @@ """ Tests for users API """ -# pylint: disable=no-member import datetime import ddt diff --git a/lms/djangoapps/mobile_api/video_outlines/tests.py b/lms/djangoapps/mobile_api/video_outlines/tests.py index 2cb59a3560..ce7eee398f 100644 --- a/lms/djangoapps/mobile_api/video_outlines/tests.py +++ b/lms/djangoapps/mobile_api/video_outlines/tests.py @@ -161,7 +161,7 @@ class TestVideoAPIMixin(object): def _setup_course_partitions(self, scheme_id='random', is_cohorted=False): """Helper method to configure the user partitions in the course.""" - self.partition_id = 0 # pylint: disable=attribute-defined-outside-init + self.partition_id = 0 self.course.user_partitions = [ UserPartition( self.partition_id, 'first_partition', 'First Partition', @@ -180,7 +180,7 @@ class TestVideoAPIMixin(object): def _setup_split_module(self, sub_block_category): """Helper method to configure a split_test unit with children of type sub_block_category.""" self._setup_course_partitions() - self.split_test = ItemFactory.create( # pylint: disable=attribute-defined-outside-init + self.split_test = ItemFactory.create( parent=self.unit, category="split_test", display_name=u"split test unit", diff --git a/lms/djangoapps/notes/models.py b/lms/djangoapps/notes/models.py index 8a81edf7df..a1f7f2fcdf 100644 --- a/lms/djangoapps/notes/models.py +++ b/lms/djangoapps/notes/models.py @@ -62,7 +62,6 @@ class Note(models.Model): """ Returns the absolute url for the note object. """ - # pylint: disable=no-member kwargs = {'course_id': text_type(self.course_id), 'note_id': str(self.pk)} return reverse('notes_api_note', kwargs=kwargs) diff --git a/lms/djangoapps/oauth2_handler/tests.py b/lms/djangoapps/oauth2_handler/tests.py index 14b6d9534b..3d023ab08a 100644 --- a/lms/djangoapps/oauth2_handler/tests.py +++ b/lms/djangoapps/oauth2_handler/tests.py @@ -158,7 +158,7 @@ class UserInfoTest(BaseTestMixin, UserInfoTestCase): full_scope = 'openid %s' % scope self.set_access_token_scope(full_scope) - token = self.access_token.token # pylint: disable=no-member + token = self.access_token.token return full_scope, token def get_with_scope(self, scope): diff --git a/lms/djangoapps/student_account/test/test_views.py b/lms/djangoapps/student_account/test/test_views.py index ed3380ed2e..ff50703535 100644 --- a/lms/djangoapps/student_account/test/test_views.py +++ b/lms/djangoapps/student_account/test/test_views.py @@ -711,8 +711,8 @@ class StudentAccountLoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMi cookies[settings.ENTERPRISE_CUSTOMER_COOKIE_NAME] = 'test-enterprise-customer' response = self.client.get(reverse('signin_user'), HTTP_ACCEPT="text/html", cookies=cookies) - self.assertIn(settings.ENTERPRISE_CUSTOMER_COOKIE_NAME, response.cookies) # pylint:disable=no-member - enterprise_cookie = response.cookies[settings.ENTERPRISE_CUSTOMER_COOKIE_NAME] # pylint:disable=no-member + self.assertIn(settings.ENTERPRISE_CUSTOMER_COOKIE_NAME, response.cookies) + enterprise_cookie = response.cookies[settings.ENTERPRISE_CUSTOMER_COOKIE_NAME] self.assertEqual(enterprise_cookie['domain'], settings.BASE_COOKIE_DOMAIN) self.assertEqual(enterprise_cookie.value, '') diff --git a/lms/djangoapps/student_account/views.py b/lms/djangoapps/student_account/views.py index 0bf89d205d..203b3adb2a 100644 --- a/lms/djangoapps/student_account/views.py +++ b/lms/djangoapps/student_account/views.py @@ -319,7 +319,7 @@ def _third_party_auth_context(request, redirect_to, tpa_hint=None): for msg in messages.get_messages(request): if msg.extra_tags.split()[0] == "social-auth": # msg may or may not be translated. Try translating [again] in case we are able to: - context['errorMessage'] = _(unicode(msg)) # pylint: disable=translation-of-non-string + context['errorMessage'] = _(unicode(msg)) break return context @@ -379,7 +379,7 @@ def _get_extended_profile_fields(): extended_profile_field_names = configuration_helpers.get_value('extended_profile_fields', []) for field_to_exclude in fields_already_showing: if field_to_exclude in extended_profile_field_names: - extended_profile_field_names.remove(field_to_exclude) # pylint: disable=no-member + extended_profile_field_names.remove(field_to_exclude) extended_profile_field_options = configuration_helpers.get_value('EXTRA_FIELD_OPTIONS', []) extended_profile_field_option_tuples = {} @@ -542,11 +542,11 @@ def account_settings_context(request): 'country': { 'options': list(countries), }, 'gender': { - 'options': [(choice[0], _(choice[1])) for choice in UserProfile.GENDER_CHOICES], # pylint: disable=translation-of-non-string + 'options': [(choice[0], _(choice[1])) for choice in UserProfile.GENDER_CHOICES], }, 'language': { 'options': released_languages(), }, 'level_of_education': { - 'options': [(choice[0], _(choice[1])) for choice in UserProfile.LEVEL_OF_EDUCATION_CHOICES], # pylint: disable=translation-of-non-string + 'options': [(choice[0], _(choice[1])) for choice in UserProfile.LEVEL_OF_EDUCATION_CHOICES], }, 'password': { 'url': reverse('password_reset'), }, 'year_of_birth': { diff --git a/lms/djangoapps/teams/search_indexes.py b/lms/djangoapps/teams/search_indexes.py index 9f754751c0..085b3d51bd 100644 --- a/lms/djangoapps/teams/search_indexes.py +++ b/lms/djangoapps/teams/search_indexes.py @@ -143,7 +143,7 @@ def course_team_post_save_callback(**kwargs): @receiver(post_delete, sender=CourseTeam, dispatch_uid='teams.signals.course_team_post_delete_callback') -def course_team_post_delete_callback(**kwargs): # pylint: disable=invalid-name +def course_team_post_delete_callback(**kwargs): """ Reindex object after delete. """ diff --git a/lms/djangoapps/teams/tests/test_models.py b/lms/djangoapps/teams/tests/test_models.py index e118ce9a2b..c5a81a74ef 100644 --- a/lms/djangoapps/teams/tests/test_models.py +++ b/lms/djangoapps/teams/tests/test_models.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -# pylint: disable=no-member """Tests for the teams API at the HTTP request level.""" import itertools from contextlib import contextmanager @@ -163,8 +162,8 @@ class TeamSignalsTest(EventTestMixin, SharedModuleStoreTestCase): team_membership_last_activity = self.team_membership.last_activity_at yield # Reload team and team membership from the database in order to pick up changes - team = CourseTeam.objects.get(id=self.team.id) # pylint: disable=maybe-no-member - team_membership = CourseTeamMembership.objects.get(id=self.team_membership.id) # pylint: disable=maybe-no-member + team = CourseTeam.objects.get(id=self.team.id) + team_membership = CourseTeamMembership.objects.get(id=self.team_membership.id) if should_update: self.assertGreater(team.last_activity_at, team_last_activity) self.assertGreater(team_membership.last_activity_at, team_membership_last_activity) diff --git a/lms/djangoapps/teams/views.py b/lms/djangoapps/teams/views.py index 23700188cf..cd7ff037f3 100644 --- a/lms/djangoapps/teams/views.py +++ b/lms/djangoapps/teams/views.py @@ -160,7 +160,7 @@ class TeamsDashboardView(GenericAPIView): "team_memberships_url": reverse('team_membership_list', request=request), "my_teams_url": reverse('teams_list', request=request), "team_membership_detail_url": reverse('team_membership_detail', args=['team_id', user.username]), - "languages": [[lang[0], _(lang[1])] for lang in settings.ALL_LANGUAGES], # pylint: disable=translation-of-non-string + "languages": [[lang[0], _(lang[1])] for lang in settings.ALL_LANGUAGES], "countries": list(countries), "disable_courseware_js": True, "teams_base_url": reverse('teams_dashboard', request=request, kwargs={'course_id': course_id}), diff --git a/lms/djangoapps/verify_student/exceptions.py b/lms/djangoapps/verify_student/exceptions.py index d8634987ef..59e7d5623f 100644 --- a/lms/djangoapps/verify_student/exceptions.py +++ b/lms/djangoapps/verify_student/exceptions.py @@ -1,8 +1,6 @@ """ Exceptions for the verify student app """ -# (Exception Class Names are sort of self-explanatory, so skipping docstring requirement) -# pylint: disable=missing-docstring class WindowExpiredException(Exception): diff --git a/lms/djangoapps/verify_student/tests/test_views.py b/lms/djangoapps/verify_student/tests/test_views.py index a7013c59ad..b2fbb5738d 100644 --- a/lms/djangoapps/verify_student/tests/test_views.py +++ b/lms/djangoapps/verify_student/tests/test_views.py @@ -1279,7 +1279,7 @@ class TestCheckoutWithEcommerceService(ModuleStoreTestCase): ecommerce api, we correctly call to that api to create a basket. """ user = UserFactory.create(username="test-username") - course_mode = CourseModeFactory.create(sku="test-sku").to_tuple() # pylint: disable=no-member + course_mode = CourseModeFactory.create(sku="test-sku").to_tuple() expected_payment_data = {'foo': 'bar'} # mock out the payment processors endpoint httpretty.register_uri( diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index c55dd919d1..eaa7842f88 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -453,8 +453,8 @@ class PayAndVerifyView(View): return url def _redirect_if_necessary( - self, message, already_verified, already_paid, is_enrolled, course_key, # pylint: disable=bad-continuation - user_is_trying_to_pay, user, sku # pylint: disable=bad-continuation + self, message, already_verified, already_paid, is_enrolled, course_key, + user_is_trying_to_pay, user, sku ): """Redirect the user to a more appropriate page if necessary. @@ -859,8 +859,8 @@ class SubmitPhotosView(View): """ @method_decorator(transaction.non_atomic_requests) - def dispatch(self, *args, **kwargs): # pylint: disable=missing-docstring - return super(SubmitPhotosView, self).dispatch(*args, **kwargs) + def dispatch(self, request, *args, **kwargs): + return super(SubmitPhotosView, self).dispatch(request, *args, **kwargs) @method_decorator(login_required) @method_decorator(outer_atomic(read_committed=True)) diff --git a/scripts/thresholds.sh b/scripts/thresholds.sh index 9648693015..8b03e59eaf 100755 --- a/scripts/thresholds.sh +++ b/scripts/thresholds.sh @@ -2,6 +2,6 @@ set -e export LOWER_PYLINT_THRESHOLD=1000 -export UPPER_PYLINT_THRESHOLD=3125 +export UPPER_PYLINT_THRESHOLD=2975 export ESLINT_THRESHOLD=5590 export STYLELINT_THRESHOLD=973