From 90b3318d01bed1d0a5c0bbf575faa5dedc5f17ac Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 07:19:59 -0800 Subject: [PATCH 01/11] Fix Pylint: I0010(bad-inline-option) --- common/lib/xmodule/xmodule/peer_grading_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/peer_grading_module.py b/common/lib/xmodule/xmodule/peer_grading_module.py index f275977a7b89..086580f06e06 100644 --- a/common/lib/xmodule/xmodule/peer_grading_module.py +++ b/common/lib/xmodule/xmodule/peer_grading_module.py @@ -616,7 +616,7 @@ def peer_grading_problem(self, data=None): elif data.get('location') is not None: problem_location = self.course_id.make_usage_key_from_deprecated_string(data.get('location')) - module = self._find_corresponding_module_for_location(problem_location) # pylint: disable-unused-variable + self._find_corresponding_module_for_location(problem_location) ajax_url = self.ajax_url html = self.system.render_template('peer_grading/peer_grading_problem.html', { From 6c06f8ce5d51f65dffc4357fcbd637ae32bc1576 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 09:37:36 -0800 Subject: [PATCH 02/11] Fix Pylint: C1001(old-style-class) --- .../contentstore/tests/test_core_caching.py | 2 +- common/lib/xmodule/xmodule/capa_base_constants.py | 4 ++-- .../combined_open_ended_modulev1.py | 4 ++-- .../open_ended_module.py | 2 +- .../self_assessment_module.py | 2 +- common/lib/xmodule/xmodule/tests/test_content.py | 4 ++-- lms/djangoapps/bulk_email/forms.py | 4 ++-- lms/djangoapps/bulk_email/models.py | 4 ++-- lms/djangoapps/certificates/models.py | 2 +- lms/djangoapps/course_wiki/editors.py | 4 ++-- lms/djangoapps/courseware/models.py | 14 +++++++------- lms/djangoapps/foldit/models.py | 2 +- lms/djangoapps/mobile_api/users/serializers.py | 4 ++-- lms/djangoapps/notifier_api/serializers.py | 2 +- lms/djangoapps/survey/admin.py | 2 +- lms/djangoapps/verify_student/models.py | 2 +- 16 files changed, 29 insertions(+), 29 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_core_caching.py b/cms/djangoapps/contentstore/tests/test_core_caching.py index 7470ac1d9d83..1d8aeec15876 100644 --- a/cms/djangoapps/contentstore/tests/test_core_caching.py +++ b/cms/djangoapps/contentstore/tests/test_core_caching.py @@ -3,7 +3,7 @@ from django.test import TestCase -class Content: +class Content(object): def __init__(self, location, content): self.location = location self.content = content diff --git a/common/lib/xmodule/xmodule/capa_base_constants.py b/common/lib/xmodule/xmodule/capa_base_constants.py index 20eab88a07a5..7739be238e8f 100644 --- a/common/lib/xmodule/xmodule/capa_base_constants.py +++ b/common/lib/xmodule/xmodule/capa_base_constants.py @@ -4,7 +4,7 @@ """ -class SHOWANSWER: +class SHOWANSWER(object): """ Constants for when to show answer """ @@ -18,7 +18,7 @@ class SHOWANSWER: NEVER = "never" -class RANDOMIZATION: +class RANDOMIZATION(object): """ Constants for problem randomization """ diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py index 2f3d2f7159cc..3a7794a0c9a8 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py @@ -67,7 +67,7 @@ SKIP_BASIC_CHECKS = False -class CombinedOpenEndedV1Module(): +class CombinedOpenEndedV1Module(object): """ This is a module that encapsulates all open ended grading (self assessment, peer assessment, etc). It transitions between problems, and support arbitrary ordering. @@ -1185,7 +1185,7 @@ def service_declaration(cls, service_name): return declaration -class CombinedOpenEndedV1Descriptor(): +class CombinedOpenEndedV1Descriptor(object): """ Module for adding combined open ended questions """ diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py index b4801ad16b17..c0f050e1fcbb 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py @@ -846,7 +846,7 @@ def score_for_attempt(self, index): return score -class OpenEndedDescriptor(): +class OpenEndedDescriptor(object): """ Module for adding open ended response questions to courses """ diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py index e9881db34434..fb82c54271d7 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/self_assessment_module.py @@ -286,7 +286,7 @@ def latest_post_assessment(self, system): return [rubric_scores] -class SelfAssessmentDescriptor(): +class SelfAssessmentDescriptor(object): """ Module for adding self assessment questions to courses """ diff --git a/common/lib/xmodule/xmodule/tests/test_content.py b/common/lib/xmodule/xmodule/tests/test_content.py index f3eea8bbc8a3..54adb9cf6ffb 100644 --- a/common/lib/xmodule/xmodule/tests/test_content.py +++ b/common/lib/xmodule/xmodule/tests/test_content.py @@ -50,13 +50,13 @@ """ -class Content: +class Content(object): def __init__(self, location, content_type): self.location = location self.content_type = content_type -class FakeGridFsItem: +class FakeGridFsItem(object): """ This class provides the basic methods to get data from a GridFS item """ diff --git a/lms/djangoapps/bulk_email/forms.py b/lms/djangoapps/bulk_email/forms.py index cacd689d8712..e9ef4c94136b 100644 --- a/lms/djangoapps/bulk_email/forms.py +++ b/lms/djangoapps/bulk_email/forms.py @@ -22,7 +22,7 @@ class CourseEmailTemplateForm(forms.ModelForm): name = forms.CharField(required=False) - class Meta: # pylint: disable=missing-docstring + class Meta(object): # pylint: disable=missing-docstring model = CourseEmailTemplate fields = ('html_template', 'plain_template', 'name') @@ -76,7 +76,7 @@ def clean_name(self): class CourseAuthorizationAdminForm(forms.ModelForm): """Input form for email enabling, allowing us to verify data.""" - class Meta: # pylint: disable=missing-docstring + class Meta(object): # pylint: disable=missing-docstring model = CourseAuthorization def clean_course_id(self): diff --git a/lms/djangoapps/bulk_email/models.py b/lms/djangoapps/bulk_email/models.py index df59c8fc1d60..e9ab0b52c482 100644 --- a/lms/djangoapps/bulk_email/models.py +++ b/lms/djangoapps/bulk_email/models.py @@ -44,7 +44,7 @@ class Email(models.Model): created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) - class Meta: # pylint: disable=missing-docstring + class Meta(object): # pylint: disable=missing-docstring abstract = True @@ -142,7 +142,7 @@ class Optout(models.Model): user = models.ForeignKey(User, db_index=True, null=True) course_id = CourseKeyField(max_length=255, db_index=True) - class Meta: # pylint: disable=missing-docstring + class Meta(object): # pylint: disable=missing-docstring unique_together = ('user', 'course_id') diff --git a/lms/djangoapps/certificates/models.py b/lms/djangoapps/certificates/models.py index d5cdd61eaf91..6d0ba63c078b 100644 --- a/lms/djangoapps/certificates/models.py +++ b/lms/djangoapps/certificates/models.py @@ -114,7 +114,7 @@ class GeneratedCertificate(models.Model): auto_now=True, default=datetime.now) error_reason = models.CharField(max_length=512, blank=True, default='') - class Meta: + class Meta(object): unique_together = (('user', 'course_id'),) @classmethod diff --git a/lms/djangoapps/course_wiki/editors.py b/lms/djangoapps/course_wiki/editors.py index 3708cec1af98..73c54c2ccbe2 100644 --- a/lms/djangoapps/course_wiki/editors.py +++ b/lms/djangoapps/course_wiki/editors.py @@ -42,7 +42,7 @@ def get_admin_widget(self, instance=None): def get_widget(self, instance=None): return CodeMirrorWidget() - class AdminMedia: + class AdminMedia(object): css = { 'all': ("wiki/markitup/skins/simple/style.css", "wiki/markitup/sets/admin/style.css",) @@ -52,7 +52,7 @@ class AdminMedia: "wiki/markitup/sets/admin/set.js", ) - class Media: + class Media(object): css = { 'all': ("js/vendor/CodeMirror/codemirror.css",) } diff --git a/lms/djangoapps/courseware/models.py b/lms/djangoapps/courseware/models.py index d1f1f45b89ed..046f3213c8dd 100644 --- a/lms/djangoapps/courseware/models.py +++ b/lms/djangoapps/courseware/models.py @@ -46,7 +46,7 @@ class StudentModule(models.Model): course_id = CourseKeyField(max_length=255, db_index=True) - class Meta: + class Meta(object): unique_together = (('student', 'module_state_key', 'course_id'),) ## Internal state of the object @@ -102,7 +102,7 @@ class StudentModuleHistory(models.Model): HISTORY_SAVING_TYPES = {'problem'} - class Meta: + class Meta(object): get_latest_by = "created" student_module = models.ForeignKey(StudentModule, db_index=True) @@ -135,7 +135,7 @@ class XBlockFieldBase(models.Model): """ Base class for all XBlock field storage. """ - class Meta: + class Meta(object): abstract = True # The name of the field @@ -163,7 +163,7 @@ class XModuleUserStateSummaryField(XBlockFieldBase): Stores data set in the Scope.user_state_summary scope by an xmodule field """ - class Meta: + class Meta(object): unique_together = (('usage_id', 'field_name'),) # The definition id for the module @@ -175,7 +175,7 @@ class XModuleStudentPrefsField(XBlockFieldBase): Stores data set in the Scope.preferences scope by an xmodule field """ - class Meta: # pylint: disable=missing-docstring + class Meta(object): # pylint: disable=missing-docstring unique_together = (('student', 'module_type', 'field_name'),) # The type of the module for these preferences @@ -189,7 +189,7 @@ class XModuleStudentInfoField(XBlockFieldBase): Stores data set in the Scope.preferences scope by an xmodule field """ - class Meta: + class Meta(object): unique_together = (('student', 'field_name'),) student = models.ForeignKey(User, db_index=True) @@ -219,7 +219,7 @@ class OfflineComputedGradeLog(models.Model): Log of when offline grades are computed. Use this to be able to show instructor when the last computed grades were done. """ - class Meta: + class Meta(object): ordering = ["-created"] get_latest_by = "created" diff --git a/lms/djangoapps/foldit/models.py b/lms/djangoapps/foldit/models.py index 4f0b3d16f611..763f3951c4a4 100644 --- a/lms/djangoapps/foldit/models.py +++ b/lms/djangoapps/foldit/models.py @@ -83,7 +83,7 @@ class PuzzleComplete(models.Model): e.g. PuzzleID 1234, set 1, subset 3. (Sets and subsets correspond to levels in the intro puzzles) """ - class Meta: + class Meta(object): # there should only be one puzzle complete entry for any particular # puzzle for any user unique_together = ('user', 'puzzle_id', 'puzzle_set', 'puzzle_subset') diff --git a/lms/djangoapps/mobile_api/users/serializers.py b/lms/djangoapps/mobile_api/users/serializers.py index f7ecb2f93183..9b12c054bfb2 100644 --- a/lms/djangoapps/mobile_api/users/serializers.py +++ b/lms/djangoapps/mobile_api/users/serializers.py @@ -80,7 +80,7 @@ def get_certificate(self, model): else: return {} - class Meta: # pylint: disable=missing-docstring + class Meta(object): # pylint: disable=missing-docstring model = CourseEnrollment fields = ('created', 'mode', 'is_active', 'course', 'certificate') lookup_field = 'username' @@ -96,7 +96,7 @@ class UserSerializer(serializers.HyperlinkedModelSerializer): lookup_field='username' ) - class Meta: # pylint: disable=missing-docstring + class Meta(object): # pylint: disable=missing-docstring model = User fields = ('id', 'username', 'email', 'name', 'course_enrollments') lookup_field = 'username' diff --git a/lms/djangoapps/notifier_api/serializers.py b/lms/djangoapps/notifier_api/serializers.py index a3877f1e5b70..1705111b4a95 100644 --- a/lms/djangoapps/notifier_api/serializers.py +++ b/lms/djangoapps/notifier_api/serializers.py @@ -63,7 +63,7 @@ def get_course_info(self, user): pass return ret - class Meta: + class Meta(object): model = User fields = ("id", "email", "name", "preferences", "course_info") read_only_fields = ("id", "email") diff --git a/lms/djangoapps/survey/admin.py b/lms/djangoapps/survey/admin.py index 07431e6d56b9..9552789b9845 100644 --- a/lms/djangoapps/survey/admin.py +++ b/lms/djangoapps/survey/admin.py @@ -10,7 +10,7 @@ class SurveyFormAdminForm(forms.ModelForm): """Form providing validation of SurveyForm content.""" - class Meta: # pylint: disable=missing-docstring + class Meta(object): # pylint: disable=missing-docstring model = SurveyForm fields = ('name', 'form') diff --git a/lms/djangoapps/verify_student/models.py b/lms/djangoapps/verify_student/models.py index 10bd7ad9ae42..4398a8297545 100644 --- a/lms/djangoapps/verify_student/models.py +++ b/lms/djangoapps/verify_student/models.py @@ -177,7 +177,7 @@ class PhotoVerification(StatusModel): # capturing it so that we can later query for the common problems. error_code = models.CharField(blank=True, max_length=50) - class Meta: + class Meta(object): abstract = True ordering = ['-created_at'] From 02486602145267a7946eb615560fd283e250b475 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 08:16:03 -0800 Subject: [PATCH 03/11] Fix Pylint: W0631(undefined-loop-variable) --- lms/djangoapps/verify_student/tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/verify_student/tests/test_models.py b/lms/djangoapps/verify_student/tests/test_models.py index 44ab2ebc0f03..f5e613b10178 100644 --- a/lms/djangoapps/verify_student/tests/test_models.py +++ b/lms/djangoapps/verify_student/tests/test_models.py @@ -311,7 +311,7 @@ def test_user_is_verified(self): attempt.status = "approved" attempt.save() - assert_true(SoftwareSecurePhotoVerification.user_is_verified(user), status) + assert_true(SoftwareSecurePhotoVerification.user_is_verified(user), attempt.status) def test_user_has_valid_or_pending(self): """ From 83fec5d092b07f7c28987a73486e50c686d8e1e7 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 01:36:57 -0800 Subject: [PATCH 04/11] Fix Pylint: W0109(duplicate-key) --- cms/envs/common.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index 646c8b9f07cf..775b78435a2a 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -134,9 +134,6 @@ # Prerequisite courses feature flag 'ENABLE_PREREQUISITE_COURSES': False, - # Toggle course milestones app/feature - 'MILESTONES_APP': False, - # Toggle course entrance exams feature 'ENTRANCE_EXAMS': False, From b9ed4b6561dc7e4de88626ef6e0d845cd4488630 Mon Sep 17 00:00:00 2001 From: stv Date: Sun, 15 Feb 2015 19:58:09 -0800 Subject: [PATCH 05/11] Fix Pylint: E1305(too-many-format-args) --- cms/djangoapps/contentstore/git_export_utils.py | 4 +++- .../contentstore/management/commands/create_course.py | 7 ++++++- common/lib/xmodule/xmodule/modulestore/exceptions.py | 7 +++++-- lms/djangoapps/licenses/tests.py | 5 ++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/cms/djangoapps/contentstore/git_export_utils.py b/cms/djangoapps/contentstore/git_export_utils.py index d2b77b49a4bb..9cefdcc287ba 100644 --- a/cms/djangoapps/contentstore/git_export_utils.py +++ b/cms/djangoapps/contentstore/git_export_utils.py @@ -161,7 +161,9 @@ def export_to_git(course_id, repo, user='', rdir=None): ident = GIT_EXPORT_DEFAULT_IDENT time_stamp = timezone.now() cwd = os.path.abspath(rdirp) - commit_msg = 'Export from Studio at {1}'.format(user, time_stamp) + commit_msg = "Export from Studio at {time_stamp}".format( + time_stamp=time_stamp, + ) try: cmd_log(['git', 'config', 'user.email', ident['email']], cwd) cmd_log(['git', 'config', 'user.name', ident['name']], cwd) diff --git a/cms/djangoapps/contentstore/management/commands/create_course.py b/cms/djangoapps/contentstore/management/commands/create_course.py index 12c7054d2a3c..19d88a597e61 100644 --- a/cms/djangoapps/contentstore/management/commands/create_course.py +++ b/cms/djangoapps/contentstore/management/commands/create_course.py @@ -40,7 +40,12 @@ def parse_args(self, *args): try: user = user_from_str(args[1]) except User.DoesNotExist: - raise CommandError("No user {} found: expected args are ".format(args[1], self.args)) + raise CommandError( + "No user {user} found: expected args are {args}".format( + user=args[1], + args=self.args, + ), + ) org = args[2] course = args[3] diff --git a/common/lib/xmodule/xmodule/modulestore/exceptions.py b/common/lib/xmodule/xmodule/modulestore/exceptions.py index d98c744009a5..12be4c398b37 100644 --- a/common/lib/xmodule/xmodule/modulestore/exceptions.py +++ b/common/lib/xmodule/xmodule/modulestore/exceptions.py @@ -50,8 +50,11 @@ def __str__(self, *args, **kwargs): """ Print info about what's duplicated """ - return '{0.store}[{0.collection}] already has {0.element_id}'.format( - self, Exception.__str__(self, *args, **kwargs) + return "{store}[{collection}] already has {element_id} ({exception})".format( + store=self.store, + collection=self.collection, + element_id=self.element_id, + exception=Exception.__str__(self, *args, **kwargs), ) diff --git a/lms/djangoapps/licenses/tests.py b/lms/djangoapps/licenses/tests.py index 0c37798b84d3..c5185ccb5b91 100644 --- a/lms/djangoapps/licenses/tests.py +++ b/lms/djangoapps/licenses/tests.py @@ -184,7 +184,10 @@ def test_import_serial_numbers(self): software_count = CourseSoftware.objects.all().count() self.assertEqual(2, software_count) - log.debug('Now we should have 3 sets of 20 serials'.format(size)) + log.debug( + "Now we should have 3 sets of %s serials", + size, + ) licenses_count = UserLicense.objects.all().count() self.assertEqual(3 * size, licenses_count) From 268cb46d9707907e92acb10a302ce322197bfe3d Mon Sep 17 00:00:00 2001 From: stv Date: Sun, 15 Feb 2015 17:26:24 -0800 Subject: [PATCH 06/11] Fix Pylint: E0211(no-method-argument) I can find no other record of this class. --- lms/djangoapps/django_comment_client/tests/test_models.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lms/djangoapps/django_comment_client/tests/test_models.py b/lms/djangoapps/django_comment_client/tests/test_models.py index 41a012a618fe..03c981528acb 100644 --- a/lms/djangoapps/django_comment_client/tests/test_models.py +++ b/lms/djangoapps/django_comment_client/tests/test_models.py @@ -34,10 +34,6 @@ def setUp(self): self.TA_role_2 = models.Role.objects.get_or_create(name="Community TA", course_id=self.course_id_2)[0] - class Dummy(): - def render_template(): - pass - def test_has_permission(self): # Whenever you add a permission to student_role, # Roles with the same FORUM_ROLE in same class also receives the same From e7e9a16379b44807066057bdbefc661c243be407 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 23 Feb 2015 00:12:36 -0800 Subject: [PATCH 07/11] Fix Pylint: W0403(relative-import) --- .../tests/mock_cs_server/test_mock_cs_server.py | 2 +- lms/djangoapps/open_ended_grading/views.py | 2 +- lms/envs/dev_with_worker.py | 2 +- lms/envs/devgroups/portal.py | 2 +- lms/lib/comment_client/comment.py | 4 ++-- lms/lib/comment_client/commentable.py | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lms/djangoapps/django_comment_client/tests/mock_cs_server/test_mock_cs_server.py b/lms/djangoapps/django_comment_client/tests/mock_cs_server/test_mock_cs_server.py index 985c8a41dc58..7518bd689577 100644 --- a/lms/djangoapps/django_comment_client/tests/mock_cs_server/test_mock_cs_server.py +++ b/lms/djangoapps/django_comment_client/tests/mock_cs_server/test_mock_cs_server.py @@ -2,7 +2,7 @@ import threading import json import urllib2 -from mock_cs_server import MockCommentServiceServer +from django_comment_client.tests.mock_cs_server.mock_cs_server import MockCommentServiceServer from nose.plugins.skip import SkipTest diff --git a/lms/djangoapps/open_ended_grading/views.py b/lms/djangoapps/open_ended_grading/views.py index 1fe0d82e3921..487e9ecb1d84 100644 --- a/lms/djangoapps/open_ended_grading/views.py +++ b/lms/djangoapps/open_ended_grading/views.py @@ -10,7 +10,7 @@ import json from student.models import unique_id_for_user -import open_ended_notifications +from open_ended_grading import open_ended_notifications from xmodule.modulestore.django import modulestore from xmodule.modulestore import search diff --git a/lms/envs/dev_with_worker.py b/lms/envs/dev_with_worker.py index 40f6ed4e1ff1..fe151c291ad7 100644 --- a/lms/envs/dev_with_worker.py +++ b/lms/envs/dev_with_worker.py @@ -12,7 +12,7 @@ # want to import all variables from base settings files # pylint: disable=wildcard-import, unused-wildcard-import -from dev import * +from lms.envs.dev import * ################################# CELERY ###################################### diff --git a/lms/envs/devgroups/portal.py b/lms/envs/devgroups/portal.py index e972d9f36c3d..c570e555f351 100644 --- a/lms/envs/devgroups/portal.py +++ b/lms/envs/devgroups/portal.py @@ -7,7 +7,7 @@ # want to import all variables from base settings files # pylint: disable=wildcard-import, unused-wildcard-import -from courses import * +from lms.envs.devgroups.courses import * # Move this to a shared file later: for class_id, db_name in CLASSES_TO_DBS.items(): diff --git a/lms/lib/comment_client/comment.py b/lms/lib/comment_client/comment.py index febb533b3314..fce94e784c19 100644 --- a/lms/lib/comment_client/comment.py +++ b/lms/lib/comment_client/comment.py @@ -1,8 +1,8 @@ from .utils import CommentClientRequestError, perform_request from .thread import Thread, _url_for_flag_abuse_thread, _url_for_unflag_abuse_thread -import models -import settings +from lms.lib.comment_client import models +from lms.lib.comment_client import settings class Comment(models.Model): diff --git a/lms/lib/comment_client/commentable.py b/lms/lib/comment_client/commentable.py index d18a7ccfb739..9ce3b2005331 100644 --- a/lms/lib/comment_client/commentable.py +++ b/lms/lib/comment_client/commentable.py @@ -1,6 +1,6 @@ """Provides base Commentable model class""" -import models -import settings +from lms.lib.comment_client import models +from lms.lib.comment_client import settings class Commentable(models.Model): From 79f9d1a70fe35267ca70a32ba71c902401f65a42 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 06:57:28 -0800 Subject: [PATCH 08/11] Fix Pylint: E1121(too-many-function-args) --- common/lib/capa/capa/safe_exec/lazymod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/capa/capa/safe_exec/lazymod.py b/common/lib/capa/capa/safe_exec/lazymod.py index d8d6115ca30a..c43c97a55f02 100644 --- a/common/lib/capa/capa/safe_exec/lazymod.py +++ b/common/lib/capa/capa/safe_exec/lazymod.py @@ -39,5 +39,5 @@ def __getattr__(self, name): submod = getattr(mod, name) except ImportError: raise AttributeError("'module' object has no attribute %r" % name) - self.__dict__[name] = LazyModule(subname, submod) + self.__dict__[name] = LazyModule(subname) return self.__dict__[name] From f03b943b9551d3ad6f99687ae0e67ce085c4a7c7 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 16 Feb 2015 06:55:08 -0800 Subject: [PATCH 09/11] Fix Pylint: W0612(unused-variable) --- .../certificates/management/commands/cert_whitelist.py | 2 +- .../certificates/management/commands/ungenerated_certs.py | 2 +- lms/djangoapps/course_wiki/tests/tests.py | 1 - lms/djangoapps/courseware/tests/__init__.py | 2 +- lms/djangoapps/django_comment_client/forum/tests.py | 4 ++-- lms/djangoapps/instructor/tests/test_legacy_enrollment.py | 2 +- lms/djangoapps/instructor/tests/test_tools.py | 2 +- lms/djangoapps/instructor_task/tests/test_api.py | 2 -- .../lms_migration/management/commands/create_groups.py | 2 +- .../lms_migration/management/commands/create_user.py | 2 +- 10 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lms/djangoapps/certificates/management/commands/cert_whitelist.py b/lms/djangoapps/certificates/management/commands/cert_whitelist.py index 1af687325087..427caced948f 100644 --- a/lms/djangoapps/certificates/management/commands/cert_whitelist.py +++ b/lms/djangoapps/certificates/management/commands/cert_whitelist.py @@ -74,7 +74,7 @@ def handle(self, *args, **options): else: user = User.objects.get(username=user_str) - cert_whitelist, created = \ + cert_whitelist, _created = \ CertificateWhitelist.objects.get_or_create( user=user, course_id=course) if options['add']: diff --git a/lms/djangoapps/certificates/management/commands/ungenerated_certs.py b/lms/djangoapps/certificates/management/commands/ungenerated_certs.py index 838e4224a3b0..67d019ce800b 100644 --- a/lms/djangoapps/certificates/management/commands/ungenerated_certs.py +++ b/lms/djangoapps/certificates/management/commands/ungenerated_certs.py @@ -124,7 +124,7 @@ def handle(self, *args, **options): diff = datetime.datetime.now(UTC) - start timeleft = diff * (total - count) / STATUS_INTERVAL hours, remainder = divmod(timeleft.seconds, 3600) - minutes, seconds = divmod(remainder, 60) + minutes, _seconds = divmod(remainder, 60) print "{0}/{1} completed ~{2:02}:{3:02}m remaining".format( count, total, hours, minutes) start = datetime.datetime.now(UTC) diff --git a/lms/djangoapps/course_wiki/tests/tests.py b/lms/djangoapps/course_wiki/tests/tests.py index fbecd44b5410..9037c16c772e 100644 --- a/lms/djangoapps/course_wiki/tests/tests.py +++ b/lms/djangoapps/course_wiki/tests/tests.py @@ -92,7 +92,6 @@ def create_course_page(self, course): course_wiki_page = referer.replace('progress', 'wiki/' + self.toy.wiki_slug + "/") ending_location = resp.redirect_chain[-1][0] - ending_status = resp.redirect_chain[-1][1] self.assertEquals(ending_location, 'http://testserver' + course_wiki_page) self.assertEquals(resp.status_code, 200) diff --git a/lms/djangoapps/courseware/tests/__init__.py b/lms/djangoapps/courseware/tests/__init__.py index 1071b2604411..9259f4ceb253 100644 --- a/lms/djangoapps/courseware/tests/__init__.py +++ b/lms/djangoapps/courseware/tests/__init__.py @@ -106,7 +106,7 @@ def setup_course(self): # username = robot{0}, password = 'test' self.users = [ UserFactory.create() - for i in range(self.USER_COUNT) + for dummy0 in range(self.USER_COUNT) ] for user in self.users: diff --git a/lms/djangoapps/django_comment_client/forum/tests.py b/lms/djangoapps/django_comment_client/forum/tests.py index b7c3c731bd46..33294548350f 100644 --- a/lms/djangoapps/django_comment_client/forum/tests.py +++ b/lms/djangoapps/django_comment_client/forum/tests.py @@ -1085,7 +1085,7 @@ def test_404_profiled_user(self, mock_request): request = RequestFactory().get("dummy_url") request.user = self.student with self.assertRaises(Http404): - response = views.user_profile( + views.user_profile( request, self.course.id.to_deprecated_string(), -999 @@ -1095,7 +1095,7 @@ def test_404_course(self, mock_request): request = RequestFactory().get("dummy_url") request.user = self.student with self.assertRaises(Http404): - response = views.user_profile( + views.user_profile( request, "non/existent/course", self.profiled_user.id diff --git a/lms/djangoapps/instructor/tests/test_legacy_enrollment.py b/lms/djangoapps/instructor/tests/test_legacy_enrollment.py index 0eb3efecee2b..3749a69a223b 100644 --- a/lms/djangoapps/instructor/tests/test_legacy_enrollment.py +++ b/lms/djangoapps/instructor/tests/test_legacy_enrollment.py @@ -188,7 +188,7 @@ def test_get_and_clean_student_list(self): """ string = "abc@test.com, def@test.com ghi@test.com \n \n jkl@test.com \n mno@test.com " - cleaned_string, cleaned_string_lc = get_and_clean_student_list(string) + cleaned_string, _cleaned_string_lc = get_and_clean_student_list(string) self.assertEqual(cleaned_string, ['abc@test.com', 'def@test.com', 'ghi@test.com', 'jkl@test.com', 'mno@test.com']) @ddt.data('http', 'https') diff --git a/lms/djangoapps/instructor/tests/test_tools.py b/lms/djangoapps/instructor/tests/test_tools.py index 0fdc2534de54..a286aa15d783 100644 --- a/lms/djangoapps/instructor/tests/test_tools.py +++ b/lms/djangoapps/instructor/tests/test_tools.py @@ -148,7 +148,7 @@ def setUp(self): week1 = ItemFactory.create(due=due, parent=course) week2 = ItemFactory.create(due=due, parent=course) - homework = ItemFactory.create( + ItemFactory.create( parent=week1, due=due ) diff --git a/lms/djangoapps/instructor_task/tests/test_api.py b/lms/djangoapps/instructor_task/tests/test_api.py index c071ba8127d1..c55e9ed706ef 100644 --- a/lms/djangoapps/instructor_task/tests/test_api.py +++ b/lms/djangoapps/instructor_task/tests/test_api.py @@ -82,7 +82,6 @@ def setUp(self): def test_submit_nonexistent_modules(self): # confirm that a rescore of a non-existent module returns an exception problem_url = InstructorTaskModuleTestCase.problem_location("NonexistentProblem") - course_id = self.course.id request = None with self.assertRaises(ItemNotFoundError): submit_rescore_problem_for_student(request, problem_url, self.student) @@ -98,7 +97,6 @@ def test_submit_nonrescorable_modules(self): # (Note that it is easier to test a scoreable but non-rescorable module in test_tasks, # where we are creating real modules.) problem_url = self.problem_section.location - course_id = self.course.id request = None with self.assertRaises(NotImplementedError): submit_rescore_problem_for_student(request, problem_url, self.student) diff --git a/lms/djangoapps/lms_migration/management/commands/create_groups.py b/lms/djangoapps/lms_migration/management/commands/create_groups.py index 6cdc0322782b..626f22c5d3c1 100644 --- a/lms/djangoapps/lms_migration/management/commands/create_groups.py +++ b/lms/djangoapps/lms_migration/management/commands/create_groups.py @@ -31,7 +31,7 @@ def create_groups(): cxfn = path(data_dir) / course_dir / 'course.xml' try: coursexml = etree.parse(cxfn) - except Exception as err: + except Exception: print "Oops, cannot read %s, skipping" % cxfn continue cxmlroot = coursexml.getroot() diff --git a/lms/djangoapps/lms_migration/management/commands/create_user.py b/lms/djangoapps/lms_migration/management/commands/create_user.py index 55590f6b2b33..53c879974ff0 100644 --- a/lms/djangoapps/lms_migration/management/commands/create_user.py +++ b/lms/djangoapps/lms_migration/management/commands/create_user.py @@ -44,7 +44,7 @@ def complete(self, text, state): def GenPasswd(length=8, chars=string.letters + string.digits): - return ''.join([choice(chars) for i in range(length)]) + return ''.join([choice(chars) for dummy0 in range(length)]) #----------------------------------------------------------------------------- # main command From 181eed241f4670822a31d8543beb1c1879c6e844 Mon Sep 17 00:00:00 2001 From: stv Date: Fri, 27 Feb 2015 21:30:18 -0800 Subject: [PATCH 10/11] Silence unrelated warnings --- .../contentstore/tests/test_core_caching.py | 3 +++ common/lib/xmodule/xmodule/tests/test_content.py | 3 +++ lms/djangoapps/certificates/models.py | 2 +- lms/djangoapps/course_wiki/editors.py | 4 ++-- lms/djangoapps/courseware/models.py | 14 +++++++------- lms/djangoapps/foldit/models.py | 2 +- .../management/commands/create_groups.py | 2 +- lms/djangoapps/notifier_api/serializers.py | 2 +- lms/djangoapps/verify_student/models.py | 2 +- 9 files changed, 20 insertions(+), 14 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_core_caching.py b/cms/djangoapps/contentstore/tests/test_core_caching.py index 1d8aeec15876..191226dbf700 100644 --- a/cms/djangoapps/contentstore/tests/test_core_caching.py +++ b/cms/djangoapps/contentstore/tests/test_core_caching.py @@ -4,6 +4,9 @@ class Content(object): + """ + Mock cached content + """ def __init__(self, location, content): self.location = location self.content = content diff --git a/common/lib/xmodule/xmodule/tests/test_content.py b/common/lib/xmodule/xmodule/tests/test_content.py index 54adb9cf6ffb..554292bc28fa 100644 --- a/common/lib/xmodule/xmodule/tests/test_content.py +++ b/common/lib/xmodule/xmodule/tests/test_content.py @@ -51,6 +51,9 @@ class Content(object): + """ + A class with location and content_type members + """ def __init__(self, location, content_type): self.location = location self.content_type = content_type diff --git a/lms/djangoapps/certificates/models.py b/lms/djangoapps/certificates/models.py index 6d0ba63c078b..2ee7079f7fc6 100644 --- a/lms/djangoapps/certificates/models.py +++ b/lms/djangoapps/certificates/models.py @@ -114,7 +114,7 @@ class GeneratedCertificate(models.Model): auto_now=True, default=datetime.now) error_reason = models.CharField(max_length=512, blank=True, default='') - class Meta(object): + class Meta(object): # pylint: disable=missing-docstring unique_together = (('user', 'course_id'),) @classmethod diff --git a/lms/djangoapps/course_wiki/editors.py b/lms/djangoapps/course_wiki/editors.py index 73c54c2ccbe2..ad6631c500cf 100644 --- a/lms/djangoapps/course_wiki/editors.py +++ b/lms/djangoapps/course_wiki/editors.py @@ -42,7 +42,7 @@ def get_admin_widget(self, instance=None): def get_widget(self, instance=None): return CodeMirrorWidget() - class AdminMedia(object): + class AdminMedia(object): # pylint: disable=missing-docstring css = { 'all': ("wiki/markitup/skins/simple/style.css", "wiki/markitup/sets/admin/style.css",) @@ -52,7 +52,7 @@ class AdminMedia(object): "wiki/markitup/sets/admin/set.js", ) - class Media(object): + class Media(object): # pylint: disable=missing-docstring css = { 'all': ("js/vendor/CodeMirror/codemirror.css",) } diff --git a/lms/djangoapps/courseware/models.py b/lms/djangoapps/courseware/models.py index 046f3213c8dd..f477b10e0435 100644 --- a/lms/djangoapps/courseware/models.py +++ b/lms/djangoapps/courseware/models.py @@ -46,7 +46,7 @@ class StudentModule(models.Model): course_id = CourseKeyField(max_length=255, db_index=True) - class Meta(object): + class Meta(object): # pylint: disable=missing-docstring unique_together = (('student', 'module_state_key', 'course_id'),) ## Internal state of the object @@ -102,7 +102,7 @@ class StudentModuleHistory(models.Model): HISTORY_SAVING_TYPES = {'problem'} - class Meta(object): + class Meta(object): # pylint: disable=missing-docstring get_latest_by = "created" student_module = models.ForeignKey(StudentModule, db_index=True) @@ -135,7 +135,7 @@ class XBlockFieldBase(models.Model): """ Base class for all XBlock field storage. """ - class Meta(object): + class Meta(object): # pylint: disable=missing-docstring abstract = True # The name of the field @@ -163,7 +163,7 @@ class XModuleUserStateSummaryField(XBlockFieldBase): Stores data set in the Scope.user_state_summary scope by an xmodule field """ - class Meta(object): + class Meta(object): # pylint: disable=missing-docstring unique_together = (('usage_id', 'field_name'),) # The definition id for the module @@ -189,7 +189,7 @@ class XModuleStudentInfoField(XBlockFieldBase): Stores data set in the Scope.preferences scope by an xmodule field """ - class Meta(object): + class Meta(object): # pylint: disable=missing-docstring unique_together = (('student', 'field_name'),) student = models.ForeignKey(User, db_index=True) @@ -207,7 +207,7 @@ class OfflineComputedGrade(models.Model): gradeset = models.TextField(null=True, blank=True) # grades, stored as JSON - class Meta: + class Meta(object): # pylint: disable=missing-docstring unique_together = (('user', 'course_id'), ) def __unicode__(self): @@ -219,7 +219,7 @@ class OfflineComputedGradeLog(models.Model): Log of when offline grades are computed. Use this to be able to show instructor when the last computed grades were done. """ - class Meta(object): + class Meta(object): # pylint: disable=missing-docstring ordering = ["-created"] get_latest_by = "created" diff --git a/lms/djangoapps/foldit/models.py b/lms/djangoapps/foldit/models.py index 763f3951c4a4..78c88080f004 100644 --- a/lms/djangoapps/foldit/models.py +++ b/lms/djangoapps/foldit/models.py @@ -83,7 +83,7 @@ class PuzzleComplete(models.Model): e.g. PuzzleID 1234, set 1, subset 3. (Sets and subsets correspond to levels in the intro puzzles) """ - class Meta(object): + class Meta(object): # pylint: disable=missing-docstring # there should only be one puzzle complete entry for any particular # puzzle for any user unique_together = ('user', 'puzzle_id', 'puzzle_set', 'puzzle_subset') diff --git a/lms/djangoapps/lms_migration/management/commands/create_groups.py b/lms/djangoapps/lms_migration/management/commands/create_groups.py index 626f22c5d3c1..37cd18b07cba 100644 --- a/lms/djangoapps/lms_migration/management/commands/create_groups.py +++ b/lms/djangoapps/lms_migration/management/commands/create_groups.py @@ -31,7 +31,7 @@ def create_groups(): cxfn = path(data_dir) / course_dir / 'course.xml' try: coursexml = etree.parse(cxfn) - except Exception: + except Exception: # pylint: disable=broad-except print "Oops, cannot read %s, skipping" % cxfn continue cxmlroot = coursexml.getroot() diff --git a/lms/djangoapps/notifier_api/serializers.py b/lms/djangoapps/notifier_api/serializers.py index 1705111b4a95..57832475d60b 100644 --- a/lms/djangoapps/notifier_api/serializers.py +++ b/lms/djangoapps/notifier_api/serializers.py @@ -63,7 +63,7 @@ def get_course_info(self, user): pass return ret - class Meta(object): + class Meta(object): # pylint: disable=missing-docstring model = User fields = ("id", "email", "name", "preferences", "course_info") read_only_fields = ("id", "email") diff --git a/lms/djangoapps/verify_student/models.py b/lms/djangoapps/verify_student/models.py index 4398a8297545..80f872c012a3 100644 --- a/lms/djangoapps/verify_student/models.py +++ b/lms/djangoapps/verify_student/models.py @@ -177,7 +177,7 @@ class PhotoVerification(StatusModel): # capturing it so that we can later query for the common problems. error_code = models.CharField(blank=True, max_length=50) - class Meta(object): + class Meta(object): # pylint: disable=missing-docstring abstract = True ordering = ['-created_at'] From 4e2927f146892bc0766dafce526ef81946e77df4 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 2 Mar 2015 20:20:31 -0800 Subject: [PATCH 11/11] Lower Pylint threshold to 5800 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 4e38c0ec5ac7..5e28dbc72f91 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=6000 +PYLINT_THRESHOLD=5800 # If the environment variable 'SHARD' is not set, default to 'all'. # This could happen if you are trying to use this script from