From 75aaf0d4a7e98115f4800deb455deb2dbeec2af2 Mon Sep 17 00:00:00 2001 From: stv Date: Sun, 15 Feb 2015 20:07:46 -0800 Subject: [PATCH 01/16] Fix Pylint: C0326(bad-whitespace) --- .../xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py | 2 +- common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py | 2 +- .../lib/xmodule/xmodule/modulestore/tests/test_xml_importer.py | 2 +- lms/envs/test.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py index f5e34a89c7..ca746f422d 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -61,7 +61,7 @@ class TestMixedModuleStore(CourseComparisonTest): ASSET_COLLECTION = 'assetstore' FS_ROOT = DATA_DIR DEFAULT_CLASS = 'xmodule.raw_module.RawDescriptor' - RENDER_TEMPLATE = lambda t_n, d, ctx = None, nsp = 'main': '' + RENDER_TEMPLATE = lambda t_n, d, ctx=None, nsp='main': '' MONGO_COURSEID = 'MITx/999/2013_Spring' XML_COURSEID1 = 'edX/toy/2012_Fall' diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py index c20be348cc..1622823d8e 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py @@ -54,7 +54,7 @@ COLLECTION = 'modulestore' ASSET_COLLECTION = 'assetstore' FS_ROOT = DATA_DIR # TODO (vshnayder): will need a real fs_root for testing load_item DEFAULT_CLASS = 'xmodule.raw_module.RawDescriptor' -RENDER_TEMPLATE = lambda t_n, d, ctx = None, nsp = 'main': '' +RENDER_TEMPLATE = lambda t_n, d, ctx=None, nsp='main': '' class ReferenceTestXBlock(XBlock, XModuleMixin): diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_xml_importer.py b/common/lib/xmodule/xmodule/modulestore/tests/test_xml_importer.py index a6b227b03b..3adde6d8d2 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_xml_importer.py @@ -28,7 +28,7 @@ class ModuleStoreNoSettings(unittest.TestCase): COLLECTION = 'modulestore' FS_ROOT = DATA_DIR DEFAULT_CLASS = 'xmodule.modulestore.tests.test_xml_importer.StubXBlock' - RENDER_TEMPLATE = lambda t_n, d, ctx = None, nsp = 'main': '' + RENDER_TEMPLATE = lambda t_n, d, ctx=None, nsp='main': '' modulestore_options = { 'default_class': DEFAULT_CLASS, diff --git a/lms/envs/test.py b/lms/envs/test.py index 43f52dc4ea..e08f7e9bbe 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -377,7 +377,7 @@ FEATURES['CLASS_DASHBOARD'] = True # Generated checkid_setup request to http://testserver/openid/provider/login/ with assocication {HMAC-SHA1}{51d49995}{s/kRmA==} import openid.oidutil -openid.oidutil.log = lambda message, level = 0: None +openid.oidutil.log = lambda message, level=0: None PLATFORM_NAME = "edX" SITE_NAME = "edx.org" From 416f7090b18bc9166a02d113f958783cf040d355 Mon Sep 17 00:00:00 2001 From: stv Date: Sun, 15 Feb 2015 20:00:31 -0800 Subject: [PATCH 02/16] Fix Pylint: C0112(empty-docstring) --- common/lib/capa/capa/inputtypes.py | 8 -------- .../management/commands/generate_serial_numbers.py | 2 -- .../licenses/management/commands/import_serial_numbers.py | 2 -- 3 files changed, 12 deletions(-) diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 055fe9c6ab..cb31fbe5c6 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -1016,8 +1016,6 @@ class Schematic(InputTypeBase): ] def _extra_context(self): - """ - """ context = { 'setup_script': '{static_url}js/capa/schematicinput.js'.format( static_url=self.capa_system.STATIC_URL), @@ -1410,8 +1408,6 @@ class EditAMoleculeInput(InputTypeBase): Attribute('missing', None)] def _extra_context(self): - """ - """ context = { 'applet_loader': '{static_url}js/capa/editamolecule.js'.format( static_url=self.capa_system.STATIC_URL), @@ -1446,8 +1442,6 @@ class DesignProtein2dInput(InputTypeBase): ] def _extra_context(self): - """ - """ context = { 'applet_loader': '{static_url}js/capa/design-protein-2d.js'.format( static_url=self.capa_system.STATIC_URL), @@ -1482,8 +1476,6 @@ class EditAGeneInput(InputTypeBase): ] def _extra_context(self): - """ - """ context = { 'applet_loader': '{static_url}js/capa/edit-a-gene.js'.format( static_url=self.capa_system.STATIC_URL), diff --git a/lms/djangoapps/licenses/management/commands/generate_serial_numbers.py b/lms/djangoapps/licenses/management/commands/generate_serial_numbers.py index 9774427b9c..7e935a831c 100644 --- a/lms/djangoapps/licenses/management/commands/generate_serial_numbers.py +++ b/lms/djangoapps/licenses/management/commands/generate_serial_numbers.py @@ -24,8 +24,6 @@ class Command(BaseCommand): args = "course_id software_id count" def handle(self, *args, **options): - """ - """ course_id, software_name, count = self._parse_arguments(args) software, _ = CourseSoftware.objects.get_or_create(course_id=course_id, diff --git a/lms/djangoapps/licenses/management/commands/import_serial_numbers.py b/lms/djangoapps/licenses/management/commands/import_serial_numbers.py index ed9ce03ca2..fbb93d3a28 100644 --- a/lms/djangoapps/licenses/management/commands/import_serial_numbers.py +++ b/lms/djangoapps/licenses/management/commands/import_serial_numbers.py @@ -24,8 +24,6 @@ class Command(BaseCommand): args = "course_id software_id serial_file" def handle(self, *args, **options): - """ - """ course_id, software_name, filename = self._parse_arguments(args) software, _ = CourseSoftware.objects.get_or_create(course_id=course_id, From 2e1400f8429c2589abec8aeb563aae9b2ada2ab5 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 04:12:31 -0800 Subject: [PATCH 03/16] Fix Pylint: W0613(unused-argument) --- common/lib/xmodule/xmodule/modulestore/xml.py | 2 +- lms/djangoapps/bulk_email/tasks.py | 4 ++-- lms/djangoapps/circuit/views.py | 2 +- lms/djangoapps/courseware/access.py | 4 ++-- lms/djangoapps/courseware/management/commands/clean_xml.py | 2 +- lms/djangoapps/courseware/middleware.py | 2 +- lms/djangoapps/courseware/tests/test_access.py | 6 +++--- lms/djangoapps/courseware/views.py | 2 +- lms/djangoapps/notes/api.py | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index d92e687fec..cb53668ed8 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -706,7 +706,7 @@ class XMLModuleStore(ModuleStoreReadBase): """ return CourseLocator(org, course, run, deprecated=True) - def get_courses(self, depth=0, **kwargs): + def get_courses(self, **kwargs): """ Returns a list of course descriptors. If there were errors on loading, some of these may be ErrorDescriptors instead. diff --git a/lms/djangoapps/bulk_email/tasks.py b/lms/djangoapps/bulk_email/tasks.py index 4cb5384137..09d1ff7cd8 100644 --- a/lms/djangoapps/bulk_email/tasks.py +++ b/lms/djangoapps/bulk_email/tasks.py @@ -92,7 +92,7 @@ BULK_EMAIL_FAILURE_ERRORS = ( ) -def _get_recipient_queryset(user_id, to_option, course_id, course_location): +def _get_recipient_queryset(user_id, to_option, course_id): """ Returns a query set of email recipients corresponding to the requested to_option category. @@ -230,7 +230,7 @@ def perform_delegate_email_batches(entry_id, course_id, task_input, action_name) ) return new_subtask - recipient_qset = _get_recipient_queryset(user_id, to_option, course_id, course.location) + recipient_qset = _get_recipient_queryset(user_id, to_option, course_id) recipient_fields = ['profile__name', 'email'] log.info(u"Task %s: Preparing to queue subtasks for sending emails for course %s, email %s, to_option %s", diff --git a/lms/djangoapps/circuit/views.py b/lms/djangoapps/circuit/views.py index 5af9ce1b44..3e8a39cb43 100644 --- a/lms/djangoapps/circuit/views.py +++ b/lms/djangoapps/circuit/views.py @@ -31,7 +31,7 @@ def circuit_line(circuit): return xml.etree.ElementTree.tostring(circuit_line) -def edit_circuit(request, circuit): +def edit_circuit(_request, circuit): try: sc = ServerCircuit.objects.get(name=circuit) except: diff --git a/lms/djangoapps/courseware/access.py b/lms/djangoapps/courseware/access.py index 8d0ce1a7ca..484c53f347 100644 --- a/lms/djangoapps/courseware/access.py +++ b/lms/djangoapps/courseware/access.py @@ -96,7 +96,7 @@ def has_access(user, action, obj, course_key=None): return _has_access_location(user, action, obj, course_key) if isinstance(obj, basestring): - return _has_access_string(user, action, obj, course_key) + return _has_access_string(user, action, obj) # Passing an unknown object here is a coding error, so rather than # returning a default, complain. @@ -487,7 +487,7 @@ def _has_access_course_key(user, action, course_key): return _dispatch(checkers, action, user, course_key) -def _has_access_string(user, action, perm, course_key): +def _has_access_string(user, action, perm): """ Check if user has certain special access, specified as string. Valid strings: diff --git a/lms/djangoapps/courseware/management/commands/clean_xml.py b/lms/djangoapps/courseware/management/commands/clean_xml.py index 2e87fc5cdf..1b576c264b 100644 --- a/lms/djangoapps/courseware/management/commands/clean_xml.py +++ b/lms/djangoapps/courseware/management/commands/clean_xml.py @@ -45,7 +45,7 @@ def export(course, export_dir): return False -def import_with_checks(course_dir, verbose=True): +def import_with_checks(course_dir): all_ok = True print "Attempting to load '{0}'".format(course_dir) diff --git a/lms/djangoapps/courseware/middleware.py b/lms/djangoapps/courseware/middleware.py index 60b803601a..c7f3218199 100644 --- a/lms/djangoapps/courseware/middleware.py +++ b/lms/djangoapps/courseware/middleware.py @@ -13,7 +13,7 @@ class RedirectUnenrolledMiddleware(object): Catch UserNotEnrolled errors thrown by `get_course_with_access` and redirect users to the course about page """ - def process_exception(self, request, exception): + def process_exception(self, _request, exception): if isinstance(exception, UserNotEnrolled): course_key = exception.course_key return redirect( diff --git a/lms/djangoapps/courseware/tests/test_access.py b/lms/djangoapps/courseware/tests/test_access.py index fe0295819e..bf0daeb872 100644 --- a/lms/djangoapps/courseware/tests/test_access.py +++ b/lms/djangoapps/courseware/tests/test_access.py @@ -88,12 +88,12 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase): def test__has_access_string(self): user = Mock(is_staff=True) - self.assertFalse(access._has_access_string(user, 'staff', 'not_global', self.course.course_key)) + self.assertFalse(access._has_access_string(user, 'staff', 'not_global')) user._has_global_staff_access.return_value = True - self.assertTrue(access._has_access_string(user, 'staff', 'global', self.course.course_key)) + self.assertTrue(access._has_access_string(user, 'staff', 'global')) - self.assertRaises(ValueError, access._has_access_string, user, 'not_staff', 'global', self.course.course_key) + self.assertRaises(ValueError, access._has_access_string, user, 'not_staff', 'global') def test__has_access_error_desc(self): descriptor = Mock() diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index b69c5c7fbd..cb7aa58fb0 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -584,7 +584,7 @@ def jump_to_id(request, course_id, module_id): @ensure_csrf_cookie -def jump_to(request, course_id, location): +def jump_to(_request, course_id, location): """ Show the page that contains a specific location. diff --git a/lms/djangoapps/notes/api.py b/lms/djangoapps/notes/api.py index 657e97f92e..920229edaf 100644 --- a/lms/djangoapps/notes/api.py +++ b/lms/djangoapps/notes/api.py @@ -148,7 +148,7 @@ def create(request, course_key): return ApiResponse(http_response=response, data=None) -def read(request, course_key, note_id): # pylint: disable=unused-argument (course_key) +def read(request, _course_key, note_id): ''' Returns a single annotation object. ''' From ee2404c0d2e26b46283bb946c1749f73c37150bb Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 08:16:27 -0800 Subject: [PATCH 04/16] Fix Pylint: E0110(abstract-class-instantiated) --- common/lib/xmodule/xmodule/tests/test_error_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/tests/test_error_module.py b/common/lib/xmodule/xmodule/tests/test_error_module.py index 28bc81db55..1b12017fbd 100644 --- a/common/lib/xmodule/xmodule/tests/test_error_module.py +++ b/common/lib/xmodule/xmodule/tests/test_error_module.py @@ -119,8 +119,8 @@ class TestErrorModuleConstruction(unittest.TestCase): """ Test that error module construction happens correctly """ - def setUp(self): + # pylint: disable=abstract-class-instantiated super(TestErrorModuleConstruction, self).setUp() field_data = Mock(spec=FieldData) self.descriptor = BrokenDescriptor( From e17504d7b867e58a71e0a6e05df1011bd728062d Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 09:03:09 -0800 Subject: [PATCH 05/16] Fix Pylint: E0012(bad-option-value) --- common/lib/xmodule/xmodule/tabs.py | 8 +------- lms/djangoapps/bulk_email/forms.py | 4 ++-- lms/djangoapps/dashboard/models.py | 2 -- lms/djangoapps/dashboard/support.py | 2 +- lms/djangoapps/notes/api.py | 4 ++-- lms/djangoapps/survey/admin.py | 2 +- 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/common/lib/xmodule/xmodule/tabs.py b/common/lib/xmodule/xmodule/tabs.py index fb0926950a..9020f058f0 100644 --- a/common/lib/xmodule/xmodule/tabs.py +++ b/common/lib/xmodule/xmodule/tabs.py @@ -1,12 +1,6 @@ """ Implement CourseTab """ -# pylint: disable=incomplete-protocol -# Note: pylint complains that we do not implement __delitem__ and __len__, although we implement __setitem__ -# and __getitem__. However, the former two do not apply to the CourseTab class so we do not implement them. -# The reason we implement the latter two is to enable callers to continue to use the CourseTab object with -# dict-type accessors. - from abc import ABCMeta, abstractmethod from xblock.fields import List @@ -15,7 +9,7 @@ from xblock.fields import List _ = lambda text: text -class CourseTab(object): # pylint: disable=incomplete-protocol +class CourseTab(object): """ The Course Tab class is a data abstraction for all tabs (i.e., course navigation links) within a course. It is an abstract class - to be inherited by various tab types. diff --git a/lms/djangoapps/bulk_email/forms.py b/lms/djangoapps/bulk_email/forms.py index 49fb840560..cacd689d87 100644 --- a/lms/djangoapps/bulk_email/forms.py +++ b/lms/djangoapps/bulk_email/forms.py @@ -17,7 +17,7 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey log = logging.getLogger(__name__) -class CourseEmailTemplateForm(forms.ModelForm): # pylint: disable=incomplete-protocol +class CourseEmailTemplateForm(forms.ModelForm): """Form providing validation of CourseEmail templates.""" name = forms.CharField(required=False) @@ -73,7 +73,7 @@ class CourseEmailTemplateForm(forms.ModelForm): # pylint: disable=incomplete-pr return name -class CourseAuthorizationAdminForm(forms.ModelForm): # pylint: disable=incomplete-protocol +class CourseAuthorizationAdminForm(forms.ModelForm): """Input form for email enabling, allowing us to verify data.""" class Meta: # pylint: disable=missing-docstring diff --git a/lms/djangoapps/dashboard/models.py b/lms/djangoapps/dashboard/models.py index 2fa3e17678..a92a418871 100644 --- a/lms/djangoapps/dashboard/models.py +++ b/lms/djangoapps/dashboard/models.py @@ -6,8 +6,6 @@ from xmodule.modulestore.mongoengine_fields import CourseKeyField class CourseImportLog(mongoengine.Document): """Mongoengine model for git log""" - # pylint: disable=incomplete-protocol - course_id = CourseKeyField(max_length=128) # NOTE: this location is not a Location object but a pathname location = mongoengine.StringField(max_length=168) diff --git a/lms/djangoapps/dashboard/support.py b/lms/djangoapps/dashboard/support.py index 02fcf6d4cd..eda7a31218 100644 --- a/lms/djangoapps/dashboard/support.py +++ b/lms/djangoapps/dashboard/support.py @@ -18,7 +18,7 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey log = logging.getLogger(__name__) -class RefundForm(forms.Form): # pylint: disable=incomplete-protocol +class RefundForm(forms.Form): """ Form for manual refunds """ diff --git a/lms/djangoapps/notes/api.py b/lms/djangoapps/notes/api.py index 920229edaf..44abb99e20 100644 --- a/lms/djangoapps/notes/api.py +++ b/lms/djangoapps/notes/api.py @@ -163,7 +163,7 @@ def read(request, _course_key, note_id): return ApiResponse(http_response=HttpResponse(), data=note.as_dict()) -def update(request, course_key, note_id): # pylint: disable=unused-argument (course_key) +def update(request, course_key, note_id): # pylint: disable=unused-argument ''' Updates an annotation object and returns a 303 with the read location. ''' @@ -247,7 +247,7 @@ def search(request, course_key): return ApiResponse(http_response=HttpResponse(), data=result) -def root(request, course_key): # pylint: disable=unused-argument (course_key, request) +def root(request, course_key): # pylint: disable=unused-argument ''' Returns version information about the API. ''' diff --git a/lms/djangoapps/survey/admin.py b/lms/djangoapps/survey/admin.py index 26b0cfd71b..07431e6d56 100644 --- a/lms/djangoapps/survey/admin.py +++ b/lms/djangoapps/survey/admin.py @@ -7,7 +7,7 @@ from django.contrib import admin from survey.models import SurveyForm -class SurveyFormAdminForm(forms.ModelForm): # pylint: disable=incomplete-protocol +class SurveyFormAdminForm(forms.ModelForm): """Form providing validation of SurveyForm content.""" class Meta: # pylint: disable=missing-docstring From 66f28fd8da1fb0b4447c0c153fb3e06feef5e78d Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 07:51:02 -0800 Subject: [PATCH 06/16] Fix Pylint: I0022(deprecated-pragma) --- cms/djangoapps/contentstore/views/xblock.py | 2 +- lms/djangoapps/courseware/module_render.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/views/xblock.py b/cms/djangoapps/contentstore/views/xblock.py index f45df73fd3..56a4289d56 100644 --- a/cms/djangoapps/contentstore/views/xblock.py +++ b/cms/djangoapps/contentstore/views/xblock.py @@ -25,7 +25,7 @@ def xblock_resource(request, block_type, uri): # pylint: disable=unused-argumen except IOError: log.info('Failed to load xblock resource', exc_info=True) raise Http404 - except Exception: # pylint: disable-msg=broad-except + except Exception: # pylint: disable=broad-except log.error('Failed to load xblock resource', exc_info=True) raise Http404 diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 260b552a34..166bf1029e 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -823,7 +823,7 @@ def xblock_resource(request, block_type, uri): # pylint: disable=unused-argumen except IOError: log.info('Failed to load xblock resource', exc_info=True) raise Http404 - except Exception: # pylint: disable-msg=broad-except + except Exception: # pylint: disable=broad-except log.error('Failed to load xblock resource', exc_info=True) raise Http404 mimetype, _ = mimetypes.guess_type(uri) From 49fb96631ed041582511d665ad62b685e5b01fd1 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 07:54:01 -0800 Subject: [PATCH 07/16] Fix Pylint: C0202(bad-classmethod-argument) --- lms/djangoapps/instructor_task/subtasks.py | 6 +++--- lms/djangoapps/shoppingcart/models.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/instructor_task/subtasks.py b/lms/djangoapps/instructor_task/subtasks.py index 093eddce98..7ca32ddace 100644 --- a/lms/djangoapps/instructor_task/subtasks.py +++ b/lms/djangoapps/instructor_task/subtasks.py @@ -165,7 +165,7 @@ class SubtaskStatus(object): self.state = state if state is not None else QUEUING @classmethod - def from_dict(self, d): + def from_dict(cls, d): """Construct a SubtaskStatus object from a dict representation.""" options = dict(d) task_id = options['task_id'] @@ -173,9 +173,9 @@ class SubtaskStatus(object): return SubtaskStatus.create(task_id, **options) @classmethod - def create(self, task_id, **options): + def create(cls, task_id, **options): """Construct a SubtaskStatus object.""" - return self(task_id, **options) + return cls(task_id, **options) def to_dict(self): """ diff --git a/lms/djangoapps/shoppingcart/models.py b/lms/djangoapps/shoppingcart/models.py index cd50e8f970..8b0c1c7268 100644 --- a/lms/djangoapps/shoppingcart/models.py +++ b/lms/djangoapps/shoppingcart/models.py @@ -1930,7 +1930,7 @@ class Donation(OrderItem): ).format(platform_name=settings.PLATFORM_NAME) @classmethod - def _line_item_description(self, course_id=None): + def _line_item_description(cls, course_id=None): """Create a line-item description for the donation. Includes the course display name if provided. From a43cd3f0ee38e0102d53d7e59801b29896364525 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 07:02:05 -0800 Subject: [PATCH 08/16] Fix Pylint: F0010(parse-error) --- common/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 common/__init__.py diff --git a/common/__init__.py b/common/__init__.py new file mode 100644 index 0000000000..e69de29bb2 From c6ef3597858a97cde92f8d162b40e338928b4397 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 06:54:09 -0800 Subject: [PATCH 09/16] Fix Pylint: E1102(not-callable) --- .../lib/capa/capa/tests/test_responsetypes.py | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index 9246a40c8c..0b801e7b5c 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -23,6 +23,23 @@ import calc from capa.responsetypes import LoncapaProblemError, \ StudentInputError, ResponseError from capa.correctmap import CorrectMap +from capa.tests.response_xml_factory import ( + AnnotationResponseXMLFactory, + ChoiceResponseXMLFactory, + CodeResponseXMLFactory, + ChoiceTextResponseXMLFactory, + CustomResponseXMLFactory, + FormulaResponseXMLFactory, + ImageResponseXMLFactory, + JavascriptResponseXMLFactory, + MultipleChoiceResponseXMLFactory, + NumericalResponseXMLFactory, + OptionResponseXMLFactory, + SchematicResponseXMLFactory, + StringResponseXMLFactory, + SymbolicResponseXMLFactory, + TrueFalseResponseXMLFactory, +) from capa.util import convert_files_to_filenames from capa.util import compare_with_tolerance from capa.xqueue_interface import dateformat @@ -77,7 +94,6 @@ class ResponseTest(unittest.TestCase): class MultiChoiceResponseTest(ResponseTest): - from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory xml_factory_class = MultipleChoiceResponseXMLFactory def test_multiple_choice_grade(self): @@ -99,7 +115,6 @@ class MultiChoiceResponseTest(ResponseTest): class TrueFalseResponseTest(ResponseTest): - from capa.tests.response_xml_factory import TrueFalseResponseXMLFactory xml_factory_class = TrueFalseResponseXMLFactory def test_true_false_grade(self): @@ -139,7 +154,6 @@ class TrueFalseResponseTest(ResponseTest): class ImageResponseTest(ResponseTest): - from capa.tests.response_xml_factory import ImageResponseXMLFactory xml_factory_class = ImageResponseXMLFactory def test_rectangle_grade(self): @@ -203,7 +217,6 @@ class ImageResponseTest(ResponseTest): class SymbolicResponseTest(ResponseTest): - from capa.tests.response_xml_factory import SymbolicResponseXMLFactory xml_factory_class = SymbolicResponseXMLFactory def test_grade_single_input_correct(self): @@ -321,7 +334,6 @@ class SymbolicResponseTest(ResponseTest): class OptionResponseTest(ResponseTest): - from capa.tests.response_xml_factory import OptionResponseXMLFactory xml_factory_class = OptionResponseXMLFactory def test_grade(self): @@ -372,7 +384,6 @@ class FormulaResponseTest(ResponseTest): """ Test the FormulaResponse class """ - from capa.tests.response_xml_factory import FormulaResponseXMLFactory xml_factory_class = FormulaResponseXMLFactory def test_grade(self): @@ -521,7 +532,6 @@ class FormulaResponseTest(ResponseTest): class StringResponseTest(ResponseTest): - from capa.tests.response_xml_factory import StringResponseXMLFactory xml_factory_class = StringResponseXMLFactory def test_backward_compatibility_for_multiple_answers(self): @@ -871,7 +881,6 @@ class StringResponseTest(ResponseTest): class CodeResponseTest(ResponseTest): - from capa.tests.response_xml_factory import CodeResponseXMLFactory xml_factory_class = CodeResponseXMLFactory def setUp(self): @@ -1063,7 +1072,6 @@ class CodeResponseTest(ResponseTest): class ChoiceResponseTest(ResponseTest): - from capa.tests.response_xml_factory import ChoiceResponseXMLFactory xml_factory_class = ChoiceResponseXMLFactory def test_radio_group_grade(self): @@ -1106,7 +1114,6 @@ class ChoiceResponseTest(ResponseTest): class JavascriptResponseTest(ResponseTest): - from capa.tests.response_xml_factory import JavascriptResponseXMLFactory xml_factory_class = JavascriptResponseXMLFactory def test_grade(self): @@ -1147,7 +1154,6 @@ class JavascriptResponseTest(ResponseTest): class NumericalResponseTest(ResponseTest): - from capa.tests.response_xml_factory import NumericalResponseXMLFactory xml_factory_class = NumericalResponseXMLFactory # We blend the line between integration (using evaluator) and exclusively @@ -1372,7 +1378,6 @@ class NumericalResponseTest(ResponseTest): class CustomResponseTest(ResponseTest): - from capa.tests.response_xml_factory import CustomResponseXMLFactory xml_factory_class = CustomResponseXMLFactory def test_inline_code(self): @@ -1924,7 +1929,6 @@ class SchematicResponseTest(ResponseTest): """ Class containing setup and tests for Schematic responsetype. """ - from capa.tests.response_xml_factory import SchematicResponseXMLFactory xml_factory_class = SchematicResponseXMLFactory def test_grade(self): @@ -1975,7 +1979,6 @@ class SchematicResponseTest(ResponseTest): class AnnotationResponseTest(ResponseTest): - from capa.tests.response_xml_factory import AnnotationResponseXMLFactory xml_factory_class = AnnotationResponseXMLFactory def test_grade(self): @@ -2017,7 +2020,6 @@ class ChoiceTextResponseTest(ResponseTest): Class containing setup and tests for ChoiceText responsetype. """ - from response_xml_factory import ChoiceTextResponseXMLFactory xml_factory_class = ChoiceTextResponseXMLFactory # `TEST_INPUTS` is a dictionary mapping from From 69695a8f1248275dd8ea4f769a63cc1e43078ba6 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 01:35:45 -0800 Subject: [PATCH 10/16] Fix Pylint: W0107(unnecessary-pass) --- cms/djangoapps/contentstore/views/component.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index ea4412e7b7..88e7e140a2 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -331,7 +331,6 @@ def get_component_templates(courselike, library=False): "Advanced component %s does not exist. It will not be added to the Studio new component menu.", category ) - pass else: log.error( "Improper format for course advanced keys! %s", From c0a7bf94f4abcf1846bd47e90370f0415b4dd76d Mon Sep 17 00:00:00 2001 From: stv Date: Sun, 15 Feb 2015 19:47:54 -0800 Subject: [PATCH 11/16] Fix Pylint: W1503(redundant-unittest-assert) --- common/lib/capa/capa/tests/test_html_render.py | 2 -- common/lib/capa/capa/tests/test_responsetypes.py | 1 - 2 files changed, 3 deletions(-) diff --git a/common/lib/capa/capa/tests/test_html_render.py b/common/lib/capa/capa/tests/test_html_render.py index f1b5249338..ca39f3b5ff 100644 --- a/common/lib/capa/capa/tests/test_html_render.py +++ b/common/lib/capa/capa/tests/test_html_render.py @@ -27,8 +27,6 @@ class CapaHtmlRenderTest(unittest.TestCase): # Render the HTML etree.XML(problem.get_html()) - # expect that we made it here without blowing up - self.assertTrue(True) def test_include_html(self): # Create a test file to include diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index 0b801e7b5c..a99456069f 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -2195,7 +2195,6 @@ class ChoiceTextResponseTest(ResponseTest): Test that `build_problem` builds valid xml """ self.build_problem() - self.assertTrue(True) def test_unchecked_input_not_validated(self): """ From 3ffa967af8fb359d5150c38164715eeeb7d6e448 Mon Sep 17 00:00:00 2001 From: stv Date: Sun, 15 Feb 2015 19:39:57 -0800 Subject: [PATCH 12/16] Fix Pylint: W0105(pointless-string-statement) --- .../peer_grading_service.py | 11 +++++----- lms/djangoapps/certificates/models.py | 20 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/peer_grading_service.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/peer_grading_service.py index da76e1867d..1ad247be74 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/peer_grading_service.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/peer_grading_service.py @@ -117,13 +117,12 @@ class PeerGradingService(GradingService): return result -""" -This is a mock peer grading service that can be used for unit tests -without making actual service calls to the grading controller -""" - - class MockPeerGradingService(object): + """ + This is a mock peer grading service that can be used for unit tests + without making actual service calls to the grading controller + """ + def get_next_submission(self, problem_location, grader_id): return { 'success': True, diff --git a/lms/djangoapps/certificates/models.py b/lms/djangoapps/certificates/models.py index 0476579da5..82100008c0 100644 --- a/lms/djangoapps/certificates/models.py +++ b/lms/djangoapps/certificates/models.py @@ -1,13 +1,3 @@ -from django.contrib.auth.models import User -from django.db import models -from django.db.models.signals import post_save -from django.dispatch import receiver -from django.conf import settings -from datetime import datetime -from model_utils import Choices -from xmodule_django.models import CourseKeyField, NoneToEmptyManager -from util.milestones_helpers import fulfill_course_milestone - """ Certificates are created for a student and an offering of a course. @@ -55,6 +45,16 @@ Eligibility: unless he has allow_certificate set to False. """ +from django.contrib.auth.models import User +from django.db import models +from django.db.models.signals import post_save +from django.dispatch import receiver +from django.conf import settings +from datetime import datetime +from model_utils import Choices +from xmodule_django.models import CourseKeyField, NoneToEmptyManager +from util.milestones_helpers import fulfill_course_milestone + class CertificateStatuses(object): deleted = 'deleted' From d21fdaac276ae621a3d08f5d91673064d5e98f3b Mon Sep 17 00:00:00 2001 From: stv Date: Sun, 15 Feb 2015 17:20:09 -0800 Subject: [PATCH 13/16] Fix Pylint: E0101(return-in-init) --- common/lib/xmodule/xmodule/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/exceptions.py b/common/lib/xmodule/xmodule/exceptions.py index a6d3686ca2..d1f05171da 100644 --- a/common/lib/xmodule/xmodule/exceptions.py +++ b/common/lib/xmodule/xmodule/exceptions.py @@ -53,4 +53,4 @@ class HeartbeatFailure(Exception): In addition to a msg, provide the name of the service. """ self.service = service - return super(HeartbeatFailure, self).__init__(msg) + super(HeartbeatFailure, self).__init__(msg) From 99008147ab8bda79a54ee42a4ad397c186d30de7 Mon Sep 17 00:00:00 2001 From: stv Date: Wed, 18 Feb 2015 12:55:37 -0800 Subject: [PATCH 14/16] Lower Pylint threshold by 200 violations --- scripts/all-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/all-tests.sh b/scripts/all-tests.sh index 1aa96a824a..3b366d9d07 100755 --- a/scripts/all-tests.sh +++ b/scripts/all-tests.sh @@ -61,7 +61,7 @@ git clean -qxfd source scripts/jenkins-common.sh # Violations thresholds for failing the build -PYLINT_THRESHOLD=6300 +PYLINT_THRESHOLD=6100 PEP8_THRESHOLD=0 # If the environment variable 'SHARD' is not set, default to 'all'. From e7b5ada5d1bf09813a7555c721ef820bb1d1f903 Mon Sep 17 00:00:00 2001 From: stv Date: Thu, 19 Feb 2015 13:07:13 -0800 Subject: [PATCH 15/16] Remove useless test Per @sarina: > `build_problem` is called in `_make_problem`, which other tests call > in this class. A failure here will arise in other tests. This test is > unnecessary. --- common/lib/capa/capa/tests/test_responsetypes.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index a99456069f..a0daa45b32 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -2190,12 +2190,6 @@ class ChoiceTextResponseTest(ResponseTest): with self.assertRaises(Exception): self.build_problem(type="invalidtextgroup") - def test_valid_xml(self): - """ - Test that `build_problem` builds valid xml - """ - self.build_problem() - def test_unchecked_input_not_validated(self): """ Test that a student can have a non numeric answer in an unselected From 237f2c329f6c4c2291c3ddba071ffc8052e9af68 Mon Sep 17 00:00:00 2001 From: stv Date: Thu, 19 Feb 2015 13:11:26 -0800 Subject: [PATCH 16/16] Add TODO comment about future test improvements --- common/lib/capa/capa/tests/test_html_render.py | 1 + 1 file changed, 1 insertion(+) diff --git a/common/lib/capa/capa/tests/test_html_render.py b/common/lib/capa/capa/tests/test_html_render.py index ca39f3b5ff..c4925603c8 100644 --- a/common/lib/capa/capa/tests/test_html_render.py +++ b/common/lib/capa/capa/tests/test_html_render.py @@ -27,6 +27,7 @@ class CapaHtmlRenderTest(unittest.TestCase): # Render the HTML etree.XML(problem.get_html()) + # TODO: This test should inspect the rendered html and assert one or more things about it def test_include_html(self): # Create a test file to include