diff --git a/cms/djangoapps/api/v1/views/course_runs.py b/cms/djangoapps/api/v1/views/course_runs.py index 83531461b8..662ac95368 100644 --- a/cms/djangoapps/api/v1/views/course_runs.py +++ b/cms/djangoapps/api/v1/views/course_runs.py @@ -20,7 +20,6 @@ from ..serializers.course_runs import ( ) -# pylint: disable=unused-argument class CourseRunViewSet(viewsets.GenericViewSet): authentication_classes = (JwtAuthentication, SessionAuthentication,) lookup_value_regex = settings.COURSE_KEY_REGEX diff --git a/cms/djangoapps/cms_user_tasks/apps.py b/cms/djangoapps/cms_user_tasks/apps.py index a35e142aaa..6df4b7f953 100644 --- a/cms/djangoapps/cms_user_tasks/apps.py +++ b/cms/djangoapps/cms_user_tasks/apps.py @@ -17,4 +17,4 @@ class CmsUserTasksConfig(AppConfig): """ Connect signal handlers. """ - from . import signals # pylint: disable=unused-variable + from . import signals # pylint: disable=unused-import diff --git a/cms/djangoapps/cms_user_tasks/signals.py b/cms/djangoapps/cms_user_tasks/signals.py index 55d8288b00..f5fc8d7d03 100644 --- a/cms/djangoapps/cms_user_tasks/signals.py +++ b/cms/djangoapps/cms_user_tasks/signals.py @@ -10,7 +10,7 @@ from django.dispatch import receiver from user_tasks.models import UserTaskArtifact from user_tasks.signals import user_task_stopped -from six.moves.urllib.parse import urljoin # pylint: disable=import-error +from six.moves.urllib.parse import urljoin from .tasks import send_task_complete_email diff --git a/cms/djangoapps/contentstore/api/views/course_quality.py b/cms/djangoapps/contentstore/api/views/course_quality.py index caebbcf4c9..cbd262e7c8 100644 --- a/cms/djangoapps/contentstore/api/views/course_quality.py +++ b/cms/djangoapps/contentstore/api/views/course_quality.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - import logging import time diff --git a/cms/djangoapps/contentstore/api/views/course_validation.py b/cms/djangoapps/contentstore/api/views/course_validation.py index af5812fac4..f230048d0e 100644 --- a/cms/djangoapps/contentstore/api/views/course_validation.py +++ b/cms/djangoapps/contentstore/api/views/course_validation.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - import logging import dateutil diff --git a/cms/djangoapps/contentstore/apps.py b/cms/djangoapps/contentstore/apps.py index 00ad73d377..7f4bc6b37c 100644 --- a/cms/djangoapps/contentstore/apps.py +++ b/cms/djangoapps/contentstore/apps.py @@ -20,4 +20,4 @@ class ContentstoreConfig(AppConfig): """ # Can't import models at module level in AppConfigs, and models get # included from the signal handlers - from .signals import handlers # pylint: disable=unused-variable + from .signals import handlers # pylint: disable=unused-import diff --git a/cms/djangoapps/contentstore/git_export_utils.py b/cms/djangoapps/contentstore/git_export_utils.py index 78141fc761..07c46322dd 100644 --- a/cms/djangoapps/contentstore/git_export_utils.py +++ b/cms/djangoapps/contentstore/git_export_utils.py @@ -13,7 +13,7 @@ from django.conf import settings from django.contrib.auth.models import User from django.utils import timezone from django.utils.translation import ugettext_lazy as _ -from six.moves.urllib.parse import urlparse # pylint: disable=import-error +from six.moves.urllib.parse import urlparse from xmodule.contentstore.django import contentstore from xmodule.modulestore.django import modulestore diff --git a/cms/djangoapps/contentstore/tasks.py b/cms/djangoapps/contentstore/tasks.py index 0fa1f56f83..227a207b41 100644 --- a/cms/djangoapps/contentstore/tasks.py +++ b/cms/djangoapps/contentstore/tasks.py @@ -260,7 +260,7 @@ def export_olx(self, user_id, course_key_string, language): self.status.set_state(u'Exporting') tarball = create_export_tarball(courselike_module, courselike_key, {}, self.status) artifact = UserTaskArtifact(status=self.status, name=u'Output') - artifact.file.save(name=os.path.basename(tarball.name), content=File(tarball)) # pylint: disable=no-member + artifact.file.save(name=os.path.basename(tarball.name), content=File(tarball)) artifact.save() # catch all exceptions so we can record useful error messages except Exception as exception: # pylint: disable=broad-except diff --git a/cms/djangoapps/contentstore/tests/test_course_settings.py b/cms/djangoapps/contentstore/tests/test_course_settings.py index 3d434ef93e..9e72d0277e 100644 --- a/cms/djangoapps/contentstore/tests/test_course_settings.py +++ b/cms/djangoapps/contentstore/tests/test_course_settings.py @@ -1082,7 +1082,8 @@ class CourseMetadataEditingTest(CourseTestCase): fresh = modulestore().get_course(self.course.id) test_model = CourseMetadata.fetch(fresh) - self.assertNotEqual(test_model['advertised_start']['value'], 1, 'advertised_start should not be updated to a wrong value') # pylint: disable=line-too-long + self.assertNotEqual(test_model['advertised_start']['value'], 1, + 'advertised_start should not be updated to a wrong value') self.assertNotEqual(test_model['days_early_for_beta']['value'], "supposed to be an integer", 'days_early_for beta should not be updated to a wrong value') diff --git a/cms/djangoapps/contentstore/tests/test_tasks.py b/cms/djangoapps/contentstore/tests/test_tasks.py index 2ac18b78b6..d4f30f66ef 100644 --- a/cms/djangoapps/contentstore/tests/test_tasks.py +++ b/cms/djangoapps/contentstore/tests/test_tasks.py @@ -27,7 +27,7 @@ TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex -def side_effect_exception(*args, **kwargs): # pylint: disable=unused-argument +def side_effect_exception(*args, **kwargs): """ Side effect for mocking which raises an exception """ diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index 2fce317d70..b4eed24e84 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -176,13 +176,13 @@ class AuthTestCase(ContentStoreTestCase): assertion_method = getattr(self, assertion_method_name) assertion_method( response, - u'Sign Up'.format( # pylint: disable=line-too-long - settings.LMS_ROOT_URL - ) + u'Sign Up'.format + (settings.LMS_ROOT_URL) ) self.assertContains( response, - u'Sign In' # pylint: disable=line-too-long + '' + 'Sign In' ) diff --git a/cms/djangoapps/contentstore/video_utils.py b/cms/djangoapps/contentstore/video_utils.py index cbee8ce619..c05eda9684 100644 --- a/cms/djangoapps/contentstore/video_utils.py +++ b/cms/djangoapps/contentstore/video_utils.py @@ -13,7 +13,7 @@ from django.core.files.images import get_image_dimensions from django.core.files.uploadedfile import SimpleUploadedFile from django.utils.translation import ugettext as _ from edxval.api import get_course_video_image_url, update_video_image -from six.moves.urllib.parse import urljoin # pylint: disable=import-error +from six.moves.urllib.parse import urljoin # Youtube thumbnail sizes. # https://img.youtube.com/vi/{youtube_id}/{thumbnail_quality}.jpg diff --git a/cms/djangoapps/contentstore/views/__init__.py b/cms/djangoapps/contentstore/views/__init__.py index 3f81e7f8f9..896789407d 100644 --- a/cms/djangoapps/contentstore/views/__init__.py +++ b/cms/djangoapps/contentstore/views/__init__.py @@ -1,5 +1,3 @@ -# pylint: disable=wildcard-import - "All view functions for contentstore, broken out into submodules" from .assets import * diff --git a/cms/djangoapps/contentstore/views/checklists.py b/cms/djangoapps/contentstore/views/checklists.py index 51b82c0f3e..4ea8e3a327 100644 --- a/cms/djangoapps/contentstore/views/checklists.py +++ b/cms/djangoapps/contentstore/views/checklists.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - from django.contrib.auth.decorators import login_required from django.core.exceptions import PermissionDenied from django.views.decorators.csrf import ensure_csrf_cookie diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index 1a22ec1a6b..4e91d8e627 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -14,7 +14,7 @@ from django.utils.translation import ugettext as _ from django.views.decorators.http import require_GET from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import UsageKey -from six.moves.urllib.parse import quote_plus # pylint: disable=import-error +from six.moves.urllib.parse import quote_plus from xblock.core import XBlock from xblock.django.request import django_to_webob_request, webob_to_django_response from xblock.exceptions import NoSuchHandlerError diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 3effe650e7..dd541849d6 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -207,7 +207,7 @@ def _course_notifications_json_get(course_action_state_id): return JsonResponse(action_state_info) -def _dismiss_notification(request, course_action_state_id): # pylint: disable=unused-argument +def _dismiss_notification(request, course_action_state_id): """ Update the display of the course notification """ @@ -381,7 +381,6 @@ def _accessible_courses_summary_iter(request, org=None): """ Filter out unusable and inaccessible courses """ - # pylint: disable=fixme # TODO remove this condition when templates purged from db if course_summary.location.course == 'templates': return False @@ -412,7 +411,6 @@ def _accessible_courses_iter(request): if isinstance(course.id, CCXLocator): return False - # pylint: disable=fixme # TODO remove this condition when templates purged from db if course.location.course == 'templates': return False @@ -441,7 +439,6 @@ def _accessible_courses_iter_for_tests(request): if isinstance(course.id, CCXLocator): return False - # pylint: disable=fixme # TODO remove this condition when templates purged from db if course.location.course == 'templates': return False diff --git a/cms/djangoapps/contentstore/views/dev.py b/cms/djangoapps/contentstore/views/dev.py index 21c4646aea..f04818e08e 100644 --- a/cms/djangoapps/contentstore/views/dev.py +++ b/cms/djangoapps/contentstore/views/dev.py @@ -3,8 +3,6 @@ Views that are only activated when the project is running in development mode. These views will NOT be shown on production: trying to access them will result in a 404 error. """ -# pylint: disable=unused-argument - from edxmako.shortcuts import render_to_response diff --git a/cms/djangoapps/contentstore/views/entrance_exam.py b/cms/djangoapps/contentstore/views/entrance_exam.py index 35f44de0ef..dcb62eb13b 100644 --- a/cms/djangoapps/contentstore/views/entrance_exam.py +++ b/cms/djangoapps/contentstore/views/entrance_exam.py @@ -41,7 +41,6 @@ def _get_default_entrance_exam_minimum_pct(): return entrance_exam_minimum_score_pct -# pylint: disable=missing-docstring def check_feature_enabled(feature_name): """ Ensure the specified feature is turned on. Return an HTTP 400 code if not. @@ -164,7 +163,7 @@ def _create_entrance_exam(request, course_key, entrance_exam_minimum_score_pct=N return HttpResponse(status=201) -def _get_entrance_exam(request, course_key): # pylint: disable=W0613 +def _get_entrance_exam(request, course_key): """ Internal workflow operation to retrieve an entrance exam """ diff --git a/cms/djangoapps/contentstore/views/error.py b/cms/djangoapps/contentstore/views/error.py index 88b90ba016..eb4b234e40 100644 --- a/cms/djangoapps/contentstore/views/error.py +++ b/cms/djangoapps/contentstore/views/error.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring,unused-argument - - import functools from django.http import HttpResponse, HttpResponseNotFound, HttpResponseServerError diff --git a/cms/djangoapps/contentstore/views/tests/test_item.py b/cms/djangoapps/contentstore/views/tests/test_item.py index f236436fca..b4d9df1873 100644 --- a/cms/djangoapps/contentstore/views/tests/test_item.py +++ b/cms/djangoapps/contentstore/views/tests/test_item.py @@ -2202,7 +2202,7 @@ class TestComponentHandler(TestCase): """ test get_aside_from_xblock called """ - def create_response(handler, request, suffix): # pylint: disable=unused-argument + def create_response(handler, request, suffix): """create dummy response""" return Response(status_code=200) diff --git a/cms/djangoapps/contentstore/views/tests/test_videos.py b/cms/djangoapps/contentstore/views/tests/test_videos.py index 2e67100bd7..07a184a104 100644 --- a/cms/djangoapps/contentstore/views/tests/test_videos.py +++ b/cms/djangoapps/contentstore/views/tests/test_videos.py @@ -1497,7 +1497,7 @@ class VideoUrlsCsvTestCase(VideoUploadTestMixin, CourseTestCase): self.assertEqual(response_video["Video ID"], original_video["edx_video_id"]) self.assertEqual(response_video["Status"], convert_video_status(original_video)) for profile in expected_profiles: - response_profile_url = response_video["{} URL".format(profile)] # pylint: disable=unicode-format-string + response_profile_url = response_video["{} URL".format(profile)] original_encoded_for_profile = next( ( original_encoded diff --git a/cms/envs/production.py b/cms/envs/production.py index 411125e239..389cafc88c 100644 --- a/cms/envs/production.py +++ b/cms/envs/production.py @@ -4,7 +4,7 @@ This is the default template for our main set of AWS servers. # We intentionally define lots of variables that aren't used, and # want to import all variables from base settings files -# pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-order +# pylint: disable=wildcard-import, unused-wildcard-import import codecs diff --git a/cms/envs/test.py b/cms/envs/test.py index 9d273a9177..b0a0ca8ed9 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -11,7 +11,7 @@ sessions. Assumes structure: # We intentionally define lots of variables that aren't used, and # want to import all variables from base settings files -# pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-order +# pylint: disable=wildcard-import, unused-wildcard-import from .common import * @@ -25,7 +25,6 @@ from openedx.core.lib.derived import derive_settings from util.db import NoOpMigrationModules # import settings from LMS for consistent behavior with CMS -# pylint: disable=unused-import from lms.envs.test import ( COMPREHENSIVE_THEME_DIRS, DEFAULT_FILE_STORAGE, diff --git a/cms/lib/xblock/field_data.py b/cms/lib/xblock/field_data.py index c4bfcc6456..dc687e257e 100644 --- a/cms/lib/xblock/field_data.py +++ b/cms/lib/xblock/field_data.py @@ -16,7 +16,7 @@ class CmsFieldData(SplitFieldData): def __init__(self, authored_data, student_data): # Make sure that we don't repeatedly nest CmsFieldData instances if isinstance(authored_data, CmsFieldData): - authored_data = authored_data._authored_data # pylint: disable=protected-access + authored_data = authored_data._authored_data self._authored_data = authored_data self._student_data = student_data diff --git a/cms/lib/xblock/tagging/tagging.py b/cms/lib/xblock/tagging/tagging.py index 3643e78a32..cfd2fbf442 100644 --- a/cms/lib/xblock/tagging/tagging.py +++ b/cms/lib/xblock/tagging/tagging.py @@ -77,7 +77,7 @@ class StructuredTagsAside(XBlockAside): return Fragment(u'') @XBlock.handler - def save_tags(self, request=None, suffix=None): # pylint: disable=unused-argument + def save_tags(self, request=None, suffix=None): """ Handler to save choosen tags with connected XBlock """ diff --git a/cms/lib/xblock/test/test_runtime.py b/cms/lib/xblock/test/test_runtime.py index 7b7df1bf23..b9f6a9932a 100644 --- a/cms/lib/xblock/test/test_runtime.py +++ b/cms/lib/xblock/test/test_runtime.py @@ -6,7 +6,7 @@ Tests of edX Studio runtime functionality from unittest import TestCase from mock import Mock -from six.moves.urllib.parse import urlparse # pylint: disable=import-error +from six.moves.urllib.parse import urlparse from cms.lib.xblock.runtime import handler_url diff --git a/common/djangoapps/course_action_state/managers.py b/common/djangoapps/course_action_state/managers.py index a43e5a68c1..e50eb9c78c 100644 --- a/common/djangoapps/course_action_state/managers.py +++ b/common/djangoapps/course_action_state/managers.py @@ -22,7 +22,7 @@ class CourseActionStateManager(models.Manager): Finds and returns all entries for this action and the given field names-and-values in kwargs. The exclude_args dict allows excluding entries with the field names-and-values in exclude_args. """ - return self.filter(action=self.ACTION, **kwargs).exclude(**(exclude_args or {})) # pylint: disable=no-member + return self.filter(action=self.ACTION, **kwargs).exclude(**(exclude_args or {})) def find_first(self, exclude_args=None, **kwargs): """ @@ -37,7 +37,7 @@ class CourseActionStateManager(models.Manager): if len(objects) == 0: raise CourseActionStateItemNotFoundError( "No entry found for action {action} with filter {filter}, excluding {exclude}".format( - action=self.ACTION, # pylint: disable=no-member + action=self.ACTION, filter=kwargs, exclude=exclude_args, )) @@ -68,7 +68,7 @@ class CourseActionUIStateManager(CourseActionStateManager): Raises CourseActionStateException if allow_not_found is False and an entry for the given course for this Action doesn't exist. """ - state_object, created = self.get_or_create(course_key=course_key, action=self.ACTION) # pylint: disable=no-member + state_object, created = self.get_or_create(course_key=course_key, action=self.ACTION) if created: if allow_not_found: @@ -76,7 +76,7 @@ class CourseActionUIStateManager(CourseActionStateManager): else: raise CourseActionStateItemNotFoundError( "Cannot update non-existent entry for course_key {course_key} and action {action}".format( - action=self.ACTION, # pylint: disable=no-member + action=self.ACTION, course_key=course_key, )) diff --git a/common/djangoapps/course_modes/admin.py b/common/djangoapps/course_modes/admin.py index cb9da9b41b..3138ea989c 100644 --- a/common/djangoapps/course_modes/admin.py +++ b/common/djangoapps/course_modes/admin.py @@ -76,10 +76,10 @@ class CourseModeForm(forms.ModelForm): default_tz = timezone(settings.TIME_ZONE) - if self.instance._expiration_datetime: # pylint: disable=protected-access + if self.instance._expiration_datetime: # django admin is using default timezone. To avoid time conversion from db to form # convert the UTC object to naive and then localize with default timezone. - _expiration_datetime = self.instance._expiration_datetime.replace( # pylint: disable=protected-access + _expiration_datetime = self.instance._expiration_datetime.replace( tzinfo=None ) self.initial["_expiration_datetime"] = default_tz.localize(_expiration_datetime) diff --git a/common/djangoapps/course_modes/apps.py b/common/djangoapps/course_modes/apps.py index fa84221508..e0420ea199 100644 --- a/common/djangoapps/course_modes/apps.py +++ b/common/djangoapps/course_modes/apps.py @@ -9,4 +9,4 @@ class CourseModesConfig(AppConfig): verbose_name = "Course Modes" def ready(self): - import course_modes.signals # pylint: disable=unused-variable + import course_modes.signals # pylint: disable=unused-import diff --git a/common/djangoapps/course_modes/tests/factories.py b/common/djangoapps/course_modes/tests/factories.py index 01031d99cd..dbd7c0bb0d 100644 --- a/common/djangoapps/course_modes/tests/factories.py +++ b/common/djangoapps/course_modes/tests/factories.py @@ -16,7 +16,6 @@ from openedx.core.djangoapps.content.course_overviews.tests.factories import Cou # Factories are self documenting -# pylint: disable=missing-docstring class CourseModeFactory(DjangoModelFactory): class Meta(object): model = CourseMode diff --git a/common/djangoapps/entitlements/api/v1/filters.py b/common/djangoapps/entitlements/api/v1/filters.py index 295bbaeba6..e67f6958bb 100644 --- a/common/djangoapps/entitlements/api/v1/filters.py +++ b/common/djangoapps/entitlements/api/v1/filters.py @@ -8,7 +8,7 @@ from entitlements.models import CourseEntitlement class CharListFilter(filters.CharFilter): """ Filters a field via a comma-delimited list of values. """ - def filter(self, qs, value): # pylint: disable=method-hidden + def filter(self, qs, value): if value not in (None, ''): value = value.split(',') diff --git a/common/djangoapps/entitlements/api/v1/tests/test_views.py b/common/djangoapps/entitlements/api/v1/tests/test_views.py index 3428ce72eb..eda867d7b7 100644 --- a/common/djangoapps/entitlements/api/v1/tests/test_views.py +++ b/common/djangoapps/entitlements/api/v1/tests/test_views.py @@ -554,7 +554,7 @@ class EntitlementViewSetTest(ModuleStoreTestCase): ) assert response.status_code == 200 - results = response.data.get('results', []) # pylint: disable=no-member + results = response.data.get('results', []) assert results == CourseEntitlementSerializer([entitlement], many=True).data def test_staff_get_only_staff_entitlements(self): @@ -583,7 +583,7 @@ class EntitlementViewSetTest(ModuleStoreTestCase): content_type='application/json', ) assert response.status_code == 200 - results = response.data.get('results', []) # pylint: disable=no-member + results = response.data.get('results', []) # Make sure that the first result isn't expired, and the second one is also not for staff users assert results[0].get('expired_at') is None and results[1].get('expired_at') is None @@ -605,7 +605,7 @@ class EntitlementViewSetTest(ModuleStoreTestCase): ) assert response.status_code == 200 - results = response.data.get('results', []) # pylint: disable=no-member + results = response.data.get('results', []) assert results[0].get('expired_at') is None and results[1].get('expired_at') def test_get_user_entitlements(self): @@ -652,7 +652,7 @@ class EntitlementViewSetTest(ModuleStoreTestCase): ) assert response.status_code == 200 - results = response.data # pylint: disable=no-member + results = response.data assert results.get('expired_at') def test_delete_and_revoke_entitlement(self): @@ -995,7 +995,7 @@ class EntitlementEnrollmentViewSetTest(ModuleStoreTestCase): expected_message = 'The Course Run ID is not a match for this Course Entitlement.' assert response.status_code == 400 - assert response.data['message'] == expected_message # pylint: disable=no-member + assert response.data['message'] == expected_message assert not CourseEnrollment.is_enrolled(self.user, fake_course_key) @patch('entitlements.models.refund_entitlement', return_value=True) diff --git a/common/djangoapps/entitlements/apps.py b/common/djangoapps/entitlements/apps.py index 9f158cc7bd..50a8d9a525 100644 --- a/common/djangoapps/entitlements/apps.py +++ b/common/djangoapps/entitlements/apps.py @@ -18,5 +18,5 @@ class EntitlementsConfig(AppConfig): """ Connect handlers to signals. """ - from . import signals # pylint: disable=unused-variable + from . import signals # pylint: disable=unused-import from .tasks import expire_old_entitlements diff --git a/common/djangoapps/entitlements/models.py b/common/djangoapps/entitlements/models.py index 348c87f92a..4041f02bc2 100644 --- a/common/djangoapps/entitlements/models.py +++ b/common/djangoapps/entitlements/models.py @@ -76,14 +76,14 @@ class CourseEntitlementPolicy(models.Model): days_since_entitlement_created = (now_timestamp - entitlement.created).days # We want to return whichever days value is less since it is then the more recent one - days_until_regain_ends = (self.regain_period.days - # pylint: disable=no-member + days_until_regain_ends = (self.regain_period.days - min(days_since_course_start, days_since_enrollment, days_since_entitlement_created)) # If the base days until expiration is less than the days until the regain period ends, use that instead if days_until_expiry < days_until_regain_ends: return days_until_expiry - return days_until_regain_ends # pylint: disable=no-member + return days_until_regain_ends def is_entitlement_regainable(self, entitlement): """ @@ -120,7 +120,7 @@ class CourseEntitlementPolicy(models.Model): # This is > because a get_days_since_created of refund_period means that that many days have passed, # which should then make the entitlement no longer refundable - if entitlement.get_days_since_created() > self.refund_period.days: # pylint: disable=no-member + if entitlement.get_days_since_created() > self.refund_period.days: return False if entitlement.enrollment_course_run: @@ -135,7 +135,7 @@ class CourseEntitlementPolicy(models.Model): """ # This is < because a get_days_since_created of expiration_period means that that many days have passed, # which should then expire the entitlement - return (entitlement.get_days_since_created() < self.expiration_period.days # pylint: disable=no-member + return (entitlement.get_days_since_created() < self.expiration_period.days and not entitlement.enrollment_course_run and not entitlement.expired_at) diff --git a/common/djangoapps/pipeline_mako/__init__.py b/common/djangoapps/pipeline_mako/__init__.py index 0ce6294309..8c82533ad8 100644 --- a/common/djangoapps/pipeline_mako/__init__.py +++ b/common/djangoapps/pipeline_mako/__init__.py @@ -85,7 +85,7 @@ def render_individual_js(package, paths, templates=None): return '\n'.join(tags) -def render_require_js_path_overrides(path_overrides): # pylint: disable=invalid-name +def render_require_js_path_overrides(path_overrides): """Render JavaScript to override default RequireJS paths. The Django pipeline appends a hash to JavaScript files, diff --git a/common/djangoapps/static_replace/test/test_static_replace.py b/common/djangoapps/static_replace/test/test_static_replace.py index 5a4a954109..38c1f45f5e 100644 --- a/common/djangoapps/static_replace/test/test_static_replace.py +++ b/common/djangoapps/static_replace/test/test_static_replace.py @@ -61,7 +61,7 @@ def test_multi_replace(): def test_process_url(): - def processor(__, prefix, quote, rest): # pylint: disable=missing-docstring + def processor(__, prefix, quote, rest): return quote + 'test' + prefix + rest + quote assert process_static_urls(STATIC_SOURCE, processor) == '"test/static/file.png"' @@ -70,7 +70,7 @@ def test_process_url(): def test_process_url_data_dir_exists(): base = '"/static/{data_dir}/file.png"'.format(data_dir=DATA_DIRECTORY) - def processor(original, prefix, quote, rest): # pylint: disable=unused-argument,missing-docstring + def processor(original, prefix, quote, rest): # pylint: disable=unused-argument return quote + 'test' + rest + quote assert process_static_urls(base, processor, data_dir=DATA_DIRECTORY) == base @@ -78,7 +78,7 @@ def test_process_url_data_dir_exists(): def test_process_url_no_match(): - def processor(__, prefix, quote, rest): # pylint: disable=missing-docstring + def processor(__, prefix, quote, rest): return quote + 'test' + prefix + rest + quote assert process_static_urls(STATIC_SOURCE, processor) == '"test/static/file.png"' diff --git a/common/djangoapps/student/admin.py b/common/djangoapps/student/admin.py index 2627db0e57..0801426cb0 100644 --- a/common/djangoapps/student/admin.py +++ b/common/djangoapps/student/admin.py @@ -269,7 +269,7 @@ class CourseEnrollmentAdmin(admin.ModelAdmin): """ Returns True if CourseEnrollment objects can be viewed via the admin view. """ - return super(CourseEnrollmentAdmin, self).has_view_permission(request, obj) # pylint: disable=no-member + return super(CourseEnrollmentAdmin, self).has_view_permission(request, obj) @_Check.is_enabled(COURSE_ENROLLMENT_ADMIN_SWITCH.is_enabled) def has_add_permission(self, request): @@ -394,7 +394,7 @@ class LoginFailuresAdmin(admin.ModelAdmin): """ Only enabled if feature is enabled. """ - return super(LoginFailuresAdmin, self).has_view_permission(request, obj) # pylint: disable=no-member + return super(LoginFailuresAdmin, self).has_view_permission(request, obj) @_Check.is_enabled(LoginFailures.is_feature_enabled) def has_delete_permission(self, request, obj=None): diff --git a/common/djangoapps/student/management/commands/manage_group.py b/common/djangoapps/student/management/commands/manage_group.py index 110b1e7d3e..368a0ec3fc 100644 --- a/common/djangoapps/student/management/commands/manage_group.py +++ b/common/djangoapps/student/management/commands/manage_group.py @@ -14,8 +14,6 @@ from django.utils.translation import gettext as _ class Command(BaseCommand): - # pylint: disable=missing-docstring - help = 'Creates the specified group, if it does not exist, and sets its permissions.' def add_arguments(self, parser): @@ -26,7 +24,7 @@ class Command(BaseCommand): def _handle_remove(self, group_name): try: - Group.objects.get(name=group_name).delete() # pylint: disable=no-member + Group.objects.get(name=group_name).delete() self.stderr.write(_('Removed group: "{}"').format(group_name)) except Group.DoesNotExist: self.stderr.write(_('Did not find a group with name "{}" - skipping.').format(group_name)) @@ -39,7 +37,7 @@ class Command(BaseCommand): return old_permissions = set() - group, created = Group.objects.get_or_create(name=group_name) # pylint: disable=no-member + group, created = Group.objects.get_or_create(name=group_name) if created: try: @@ -107,7 +105,7 @@ class Command(BaseCommand): content_type = ContentType.objects.get_for_model(model_class) try: - new_permission = Permission.objects.get( # pylint: disable=no-member + new_permission = Permission.objects.get( content_type=content_type, codename=codename, ) diff --git a/common/djangoapps/student/management/commands/manage_user.py b/common/djangoapps/student/management/commands/manage_user.py index 4c2a102322..80e2315dc8 100644 --- a/common/djangoapps/student/management/commands/manage_user.py +++ b/common/djangoapps/student/management/commands/manage_user.py @@ -30,8 +30,6 @@ def is_valid_django_hash(encoded): class Command(BaseCommand): - # pylint: disable=missing-docstring - help = 'Creates the specified user, if it does not exist, and sets its groups.' def add_arguments(self, parser): @@ -135,7 +133,7 @@ class Command(BaseCommand): for group_name in groups or set(): try: - group = Group.objects.get(name=group_name) # pylint: disable=no-member + group = Group.objects.get(name=group_name) new_groups.add(group) except Group.DoesNotExist: # warn, but move on. diff --git a/common/djangoapps/student/management/tests/test_bulk_change_enrollment.py b/common/djangoapps/student/management/tests/test_bulk_change_enrollment.py index 404f8b8253..c2572f5678 100644 --- a/common/djangoapps/student/management/tests/test_bulk_change_enrollment.py +++ b/common/djangoapps/student/management/tests/test_bulk_change_enrollment.py @@ -244,7 +244,7 @@ class BulkChangeEnrollmentTests(SharedModuleStoreTestCase): def _assert_mode_changed(self, mock_tracker, course, user, to_mode): """Confirm the analytics event was emitted.""" - mock_tracker.emit.assert_has_calls( # pylint: disable=maybe-no-member + mock_tracker.emit.assert_has_calls( [ call( EVENT_NAME_ENROLLMENT_MODE_CHANGED, diff --git a/common/djangoapps/student/management/tests/test_manage_group.py b/common/djangoapps/student/management/tests/test_manage_group.py index 92ffdea2d5..4eef828a67 100644 --- a/common/djangoapps/student/management/tests/test_manage_group.py +++ b/common/djangoapps/student/management/tests/test_manage_group.py @@ -42,7 +42,7 @@ class TestManageGroupCommand(TestCase): group = Group.objects.create(name=group_name) for codename in permission_codenames: group.permissions.add( - Permission.objects.get(content_type=content_type, codename=codename) # pylint: disable=no-member + Permission.objects.get(content_type=content_type, codename=codename) ) def check_group_permissions(self, group_permissions): @@ -58,7 +58,7 @@ class TestManageGroupCommand(TestCase): """ DRY helper. """ - self.assertEqual(set(group_names), {g.name for g in Group.objects.all()}) # pylint: disable=no-member + self.assertEqual(set(group_names), {g.name for g in Group.objects.all()}) def check_permissions(self, group_name, permission_codenames): """ @@ -66,7 +66,7 @@ class TestManageGroupCommand(TestCase): """ self.assertEqual( set(permission_codenames), - {p.codename for p in Group.objects.get(name=group_name).permissions.all()} # pylint: disable=no-member + {p.codename for p in Group.objects.get(name=group_name).permissions.all()} ) @ddt.data( diff --git a/common/djangoapps/student/management/tests/test_manage_user.py b/common/djangoapps/student/management/tests/test_manage_user.py index 0298964d5b..f6fc6d911f 100644 --- a/common/djangoapps/student/management/tests/test_manage_user.py +++ b/common/djangoapps/student/management/tests/test_manage_user.py @@ -27,7 +27,6 @@ class TestManageUserCommand(TestCase): """ Ensures that users are created if they don't exist and reused if they do. """ - # pylint: disable=no-member self.assertEqual([], list(User.objects.all())) call_command('manage_user', TEST_USERNAME, TEST_EMAIL) user = User.objects.get(username=TEST_USERNAME) @@ -43,7 +42,6 @@ class TestManageUserCommand(TestCase): """ Ensures that users are removed if they exist and exit cleanly otherwise. """ - # pylint: disable=no-member User.objects.create(username=TEST_USERNAME, email=TEST_EMAIL) self.assertEqual([(TEST_USERNAME, TEST_EMAIL)], [(u.username, u.email) for u in User.objects.all()]) call_command('manage_user', TEST_USERNAME, TEST_EMAIL, '--remove') @@ -108,7 +106,6 @@ class TestManageUserCommand(TestCase): Ensure that the operation is aborted if the username matches an existing user account but the supplied email doesn't match. """ - # pylint: disable=no-member User.objects.create(username=TEST_USERNAME, email=TEST_EMAIL) with self.assertRaises(CommandError) as exc_context: call_command('manage_user', TEST_USERNAME, 'other@example.com') @@ -150,7 +147,7 @@ class TestManageUserCommand(TestCase): expected_staff, expected_super = expected_bits args = [opt for bit, opt in ((expected_staff, '--staff'), (expected_super, '--superuser')) if bit] call_command('manage_user', TEST_USERNAME, TEST_EMAIL, *args) - user = User.objects.all().first() # pylint: disable=no-member + user = User.objects.all().first() self.assertEqual(user.is_staff, expected_staff) self.assertEqual(user.is_superuser, expected_super) diff --git a/common/djangoapps/student/management/tests/test_transfer_students.py b/common/djangoapps/student/management/tests/test_transfer_students.py index 05118b1146..40696e5491 100644 --- a/common/djangoapps/student/management/tests/test_transfer_students.py +++ b/common/djangoapps/student/management/tests/test_transfer_students.py @@ -13,7 +13,7 @@ from opaque_keys.edx import locator from six import text_type from course_modes.models import CourseMode -from shoppingcart.models import CertificateItem, Order # pylint: disable=import-error +from shoppingcart.models import CertificateItem, Order from student.models import ( EVENT_NAME_ENROLLMENT_ACTIVATED, EVENT_NAME_ENROLLMENT_DEACTIVATED, @@ -93,7 +93,7 @@ class TestTransferStudents(ModuleStoreTestCase): self.assertTrue(self.signal_fired) # Confirm the analytics event was emitted. - self.mock_tracker.emit.assert_has_calls( # pylint: disable=maybe-no-member + self.mock_tracker.emit.assert_has_calls( [ call( EVENT_NAME_ENROLLMENT_ACTIVATED, diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index 66826e05fe..172e3243a2 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -535,7 +535,7 @@ class UserProfile(models.Model): if self.gender: return self.__enumerable_to_display(self.GENDER_CHOICES, self.gender) - def get_meta(self): # pylint: disable=missing-docstring + def get_meta(self): # pylint: disable=missing-function-docstring js_str = self.meta if not js_str: js_str = dict() @@ -544,7 +544,7 @@ class UserProfile(models.Model): return js_str - def set_meta(self, meta_json): # pylint: disable=missing-docstring + def set_meta(self, meta_json): self.meta = json.dumps(meta_json) def set_login_session(self, session_id=None): @@ -625,7 +625,7 @@ class UserProfile(models.Model): @receiver(models.signals.post_save, sender=UserProfile) -def invalidate_user_profile_country_cache(sender, instance, **kwargs): # pylint: disable=unused-argument, invalid-name +def invalidate_user_profile_country_cache(sender, instance, **kwargs): # pylint: disable=unused-argument """Invalidate the cache of country in UserProfile model. """ changed_fields = getattr(instance, '_changed_fields', {}) @@ -659,7 +659,6 @@ def user_profile_post_save_callback(sender, **kwargs): Emit analytics events after saving the UserProfile. """ user_profile = kwargs['instance'] - # pylint: disable=protected-access emit_field_changed_events( user_profile, user_profile.user, @@ -714,7 +713,6 @@ def user_post_save_callback(sender, **kwargs): # Because `emit_field_changed_events` removes the record of the fields that # were changed, wait to do that until after we've checked them as part of # the condition on whether we want to check for automatic enrollments. - # pylint: disable=protected-access emit_field_changed_events( user, user, @@ -1236,7 +1234,6 @@ class CourseEnrollment(models.Model): Returns a boolean value regarding whether the user has access to enroll in the course. Returns False if the enrollment has been closed. """ - # pylint: disable=import-error from openedx.core.djangoapps.enrollments.permissions import ENROLL_IN_COURSE return not user.has_perm(ENROLL_IN_COURSE, course) @@ -2048,7 +2045,7 @@ class FBEEnrollmentExclusion(models.Model): @receiver(models.signals.post_save, sender=CourseEnrollment) @receiver(models.signals.post_delete, sender=CourseEnrollment) -def invalidate_enrollment_mode_cache(sender, instance, **kwargs): # pylint: disable=unused-argument, invalid-name +def invalidate_enrollment_mode_cache(sender, instance, **kwargs): # pylint: disable=unused-argument """ Invalidate the cache of CourseEnrollment model. """ @@ -2252,7 +2249,7 @@ class CourseAccessRole(models.Model): """ Lexigraphic sort """ - return self._key < other._key # pylint: disable=protected-access + return self._key < other._key def __str__(self): return "[CourseAccessRole] user: {} role: {} org: {} course: {}".format(self.user.username, self.role, self.org, self.course_id) @@ -2389,7 +2386,7 @@ def create_comments_service_user(user): @receiver(user_logged_in) -def log_successful_login(sender, request, user, **kwargs): # pylint: disable=unused-argument +def log_successful_login(sender, request, user, **kwargs): """Handler to log when logins have occurred successfully.""" if settings.FEATURES['SQUELCH_PII_IN_LOGS']: AUDIT_LOG.info(u"Login success - user.id: {0}".format(user.id)) @@ -2398,7 +2395,7 @@ def log_successful_login(sender, request, user, **kwargs): # pylint: disable=un @receiver(user_logged_out) -def log_successful_logout(sender, request, user, **kwargs): # pylint: disable=unused-argument +def log_successful_logout(sender, request, user, **kwargs): """Handler to log when logouts have occurred successfully.""" if hasattr(request, 'user'): if settings.FEATURES['SQUELCH_PII_IN_LOGS']: @@ -2409,7 +2406,7 @@ def log_successful_logout(sender, request, user, **kwargs): # pylint: disable=u @receiver(user_logged_in) @receiver(user_logged_out) -def enforce_single_login(sender, request, user, signal, **kwargs): # pylint: disable=unused-argument +def enforce_single_login(sender, request, user, signal, **kwargs): """ Sets the current session id in the user profile, to prevent concurrent logins. @@ -2675,7 +2672,7 @@ class LanguageProficiency(models.Model): ) -class SocialLink(models.Model): # pylint: disable=model-missing-unicode +class SocialLink(models.Model): """ Represents a URL connecting a particular social platform to a user's social profile. diff --git a/common/djangoapps/student/signals/receivers.py b/common/djangoapps/student/signals/receivers.py index bb0213a39b..57e673ce4e 100644 --- a/common/djangoapps/student/signals/receivers.py +++ b/common/djangoapps/student/signals/receivers.py @@ -9,7 +9,7 @@ from student.helpers import USERNAME_EXISTS_MSG_FMT, AccountValidationError from student.models import is_email_retired, is_username_retired -def on_user_updated(sender, instance, **kwargs): # pylint: disable=unused-argument +def on_user_updated(sender, instance, **kwargs): """ Check for retired usernames. """ diff --git a/common/djangoapps/student/tasks.py b/common/djangoapps/student/tasks.py index 56a7565ab5..30f00e92c4 100644 --- a/common/djangoapps/student/tasks.py +++ b/common/djangoapps/student/tasks.py @@ -6,7 +6,7 @@ This file contains celery tasks for sending email import logging from celery.exceptions import MaxRetriesExceededError -from celery.task import task # pylint: disable=no-name-in-module, import-error +from celery.task import task from django.conf import settings from django.contrib.auth.models import User from django.contrib.sites.models import Site @@ -58,7 +58,7 @@ def send_activation_email(self, msg_string, from_address=None): dest_addr, exc_info=True ) - except Exception: # pylint: disable=bare-except + except Exception: log.exception( 'Unable to send activation email to user from "%s" to "%s"', from_address, diff --git a/common/djangoapps/student/tests/factories.py b/common/djangoapps/student/tests/factories.py index f8649a3341..0274788602 100644 --- a/common/djangoapps/student/tests/factories.py +++ b/common/djangoapps/student/tests/factories.py @@ -27,7 +27,6 @@ from student.models import ( ) # Factories are self documenting -# pylint: disable=missing-docstring TEST_PASSWORD = 'test' @@ -90,7 +89,7 @@ class UserFactory(DjangoModelFactory): date_joined = datetime(2011, 1, 1, tzinfo=UTC) @factory.post_generation - def profile(obj, create, extracted, **kwargs): # pylint: disable=unused-argument, no-self-argument + def profile(obj, create, extracted, **kwargs): # pylint: disable=unused-argument, missing-function-docstring if create: obj.save() return UserProfileFactory.create(user=obj, **kwargs) diff --git a/common/djangoapps/student/tests/test_certificates.py b/common/djangoapps/student/tests/test_certificates.py index 2982796991..f7d5c1d5b7 100644 --- a/common/djangoapps/student/tests/test_certificates.py +++ b/common/djangoapps/student/tests/test_certificates.py @@ -13,9 +13,9 @@ from mock import patch from pytz import UTC from course_modes.models import CourseMode -from lms.djangoapps.certificates.api import get_certificate_url # pylint: disable=import-error -from lms.djangoapps.certificates.models import CertificateStatuses # pylint: disable=import-error -from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error +from lms.djangoapps.certificates.api import get_certificate_url +from lms.djangoapps.certificates.models import CertificateStatuses +from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory from student.models import LinkedInAddToProfileConfiguration from student.tests.factories import CourseEnrollmentFactory, UserFactory from xmodule.modulestore import ModuleStoreEnum diff --git a/common/djangoapps/student/tests/test_credit.py b/common/djangoapps/student/tests/test_credit.py index 6c81125b47..c3b5e218be 100644 --- a/common/djangoapps/student/tests/test_credit.py +++ b/common/djangoapps/student/tests/test_credit.py @@ -189,7 +189,7 @@ class CreditCourseDashboardTest(ModuleStoreTestCase): def _purchase_credit(self): """Purchase credit from a provider in the course. """ self.enrollment.mode = "credit" - self.enrollment.save() # pylint: disable=no-member + self.enrollment.save() CourseEnrollmentAttribute.objects.create( enrollment=self.enrollment, diff --git a/common/djangoapps/student/tests/test_models.py b/common/djangoapps/student/tests/test_models.py index 072fdbfbec..fd18cbba39 100644 --- a/common/djangoapps/student/tests/test_models.py +++ b/common/djangoapps/student/tests/test_models.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - import datetime import hashlib diff --git a/common/djangoapps/student/tests/tests.py b/common/djangoapps/student/tests/tests.py index c5953682ce..be13a90e8b 100644 --- a/common/djangoapps/student/tests/tests.py +++ b/common/djangoapps/student/tests/tests.py @@ -26,12 +26,12 @@ from six import text_type from six.moves import range from six.moves.urllib.parse import quote -import shoppingcart # pylint: disable=import-error -from bulk_email.models import Optout # pylint: disable=import-error +import shoppingcart +from bulk_email.models import Optout from course_modes.models import CourseMode from course_modes.tests.factories import CourseModeFactory -from lms.djangoapps.certificates.models import CertificateStatuses # pylint: disable=import-error -from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error +from lms.djangoapps.certificates.models import CertificateStatuses +from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory from lms.djangoapps.verify_student.tests import TestVerificationBase from openedx.core.djangoapps.catalog.tests.factories import CourseFactory as CatalogCourseFactory from openedx.core.djangoapps.catalog.tests.factories import CourseRunFactory, ProgramFactory, generate_course_run_key @@ -715,7 +715,7 @@ class EnrollmentEventTestMixin(EventTestMixin): def assert_enrollment_mode_change_event_was_emitted(self, user, course_key, mode): """Ensures an enrollment mode change event was emitted""" - self.mock_tracker.emit.assert_called_once_with( # pylint: disable=maybe-no-member + self.mock_tracker.emit.assert_called_once_with( 'edx.course.enrollment.mode_changed', { 'course_id': text_type(course_key), @@ -727,7 +727,7 @@ class EnrollmentEventTestMixin(EventTestMixin): def assert_enrollment_event_was_emitted(self, user, course_key): """Ensures an enrollment event was emitted since the last event related assertion""" - self.mock_tracker.emit.assert_called_once_with( # pylint: disable=maybe-no-member + self.mock_tracker.emit.assert_called_once_with( 'edx.course.enrollment.activated', { 'course_id': text_type(course_key), @@ -739,7 +739,7 @@ class EnrollmentEventTestMixin(EventTestMixin): def assert_unenrollment_event_was_emitted(self, user, course_key): """Ensures an unenrollment event was emitted since the last event related assertion""" - self.mock_tracker.emit.assert_called_once_with( # pylint: disable=maybe-no-member + self.mock_tracker.emit.assert_called_once_with( 'edx.course.enrollment.deactivated', { 'course_id': text_type(course_key), diff --git a/common/djangoapps/student/views/__init__.py b/common/djangoapps/student/views/__init__.py index c11803e8f9..e10dd7b8a8 100644 --- a/common/djangoapps/student/views/__init__.py +++ b/common/djangoapps/student/views/__init__.py @@ -3,5 +3,5 @@ Combines all of the broken out student views """ -from .dashboard import * # pylint: disable=wildcard-import -from .management import * # pylint: disable=wildcard-import +from .dashboard import * +from .management import * diff --git a/common/djangoapps/student/views/dashboard.py b/common/djangoapps/student/views/dashboard.py index 4d0f295c91..ba55a80b30 100644 --- a/common/djangoapps/student/views/dashboard.py +++ b/common/djangoapps/student/views/dashboard.py @@ -25,7 +25,7 @@ from bulk_email.models import Optout from course_modes.models import CourseMode from edxmako.shortcuts import render_to_response, render_to_string from entitlements.models import CourseEntitlement -from lms.djangoapps.commerce.utils import EcommerceService # pylint: disable=import-error +from lms.djangoapps.commerce.utils import EcommerceService from lms.djangoapps.courseware.access import has_access from lms.djangoapps.experiments.utils import get_dashboard_course_info from lms.djangoapps.verify_student.services import IDVerificationService @@ -150,7 +150,7 @@ def _allow_donation(course_modes, course_id, enrollment): ) -def _create_recent_enrollment_message(course_enrollments, course_modes): # pylint: disable=invalid-name +def _create_recent_enrollment_message(course_enrollments, course_modes): """ Builds a recent course enrollment message. diff --git a/common/djangoapps/student/views/management.py b/common/djangoapps/student/views/management.py index 7b4fec74c7..24f4bb1a33 100644 --- a/common/djangoapps/student/views/management.py +++ b/common/djangoapps/student/views/management.py @@ -692,7 +692,7 @@ def do_email_change_request(user, new_email, activation_key=None, secondary_emai @ensure_csrf_cookie -def activate_secondary_email(request, key): # pylint: disable=unused-argument +def activate_secondary_email(request, key): """ This is called when the activation link is clicked. We activate the secondary email for the requested user. @@ -720,7 +720,7 @@ def activate_secondary_email(request, key): # pylint: disable=unused-argument @ensure_csrf_cookie -def confirm_email_change(request, key): # pylint: disable=unused-argument +def confirm_email_change(request, key): """ User requested a new e-mail. This is called when the activation link is clicked. We confirm with the old e-mail, and update diff --git a/common/djangoapps/terrain/stubs/catalog.py b/common/djangoapps/terrain/stubs/catalog.py index 7ec477a6c0..d2cdebe5dc 100644 --- a/common/djangoapps/terrain/stubs/catalog.py +++ b/common/djangoapps/terrain/stubs/catalog.py @@ -1,12 +1,12 @@ """ Stub implementation of catalog service for acceptance tests """ -# pylint: disable=invalid-name, missing-docstring +# pylint: disable=invalid-name import re -import six.moves.urllib.parse # pylint: disable=import-error +import six.moves.urllib.parse from .http import StubHttpRequestHandler, StubHttpService diff --git a/common/djangoapps/terrain/stubs/comments.py b/common/djangoapps/terrain/stubs/comments.py index 57f022f974..4d46e0081c 100644 --- a/common/djangoapps/terrain/stubs/comments.py +++ b/common/djangoapps/terrain/stubs/comments.py @@ -6,7 +6,7 @@ Stub implementation of cs_comments_service for acceptance tests import re from collections import OrderedDict -import six.moves.urllib.parse # pylint: disable=import-error +import six.moves.urllib.parse from .http import StubHttpRequestHandler, StubHttpService diff --git a/common/djangoapps/terrain/stubs/ecommerce.py b/common/djangoapps/terrain/stubs/ecommerce.py index bda35a7ae0..96835ab0c1 100644 --- a/common/djangoapps/terrain/stubs/ecommerce.py +++ b/common/djangoapps/terrain/stubs/ecommerce.py @@ -5,14 +5,15 @@ Stub implementation of ecommerce service for acceptance tests import re -import six.moves.urllib.parse # pylint: disable=import-error +import six.moves.urllib.parse from .http import StubHttpRequestHandler, StubHttpService -class StubEcommerceServiceHandler(StubHttpRequestHandler): # pylint: disable=missing-docstring +class StubEcommerceServiceHandler(StubHttpRequestHandler): # pylint: disable=missing-class-docstring - def do_GET(self): # pylint: disable=invalid-name, missing-docstring + # pylint: disable=missing-function-docstring + def do_GET(self): pattern_handlers = { '/api/v2/orders/$': self.get_orders_list, } @@ -59,5 +60,5 @@ class StubEcommerceServiceHandler(StubHttpRequestHandler): # pylint: disable=mi self.send_json_response(orders) -class StubEcommerceService(StubHttpService): # pylint: disable=missing-docstring +class StubEcommerceService(StubHttpService): HANDLER_CLASS = StubEcommerceServiceHandler diff --git a/common/djangoapps/terrain/stubs/edxnotes.py b/common/djangoapps/terrain/stubs/edxnotes.py index b32f3b174f..9d1b83697a 100644 --- a/common/djangoapps/terrain/stubs/edxnotes.py +++ b/common/djangoapps/terrain/stubs/edxnotes.py @@ -11,7 +11,7 @@ from math import ceil from uuid import uuid4 import six -from six.moves.urllib.parse import urlencode # pylint: disable=import-error +from six.moves.urllib.parse import urlencode from .http import StubHttpRequestHandler, StubHttpService diff --git a/common/djangoapps/terrain/stubs/http.py b/common/djangoapps/terrain/stubs/http.py index cf3523f230..7cf277b89f 100644 --- a/common/djangoapps/terrain/stubs/http.py +++ b/common/djangoapps/terrain/stubs/http.py @@ -10,8 +10,8 @@ from logging import getLogger import six from lazy import lazy -from six.moves.BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer # pylint: disable=import-error -from six.moves.socketserver import ThreadingMixIn # pylint: disable=import-error +from six.moves.BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer +from six.moves.socketserver import ThreadingMixIn LOGGER = getLogger(__name__) diff --git a/common/djangoapps/terrain/stubs/tests/test_edxnotes.py b/common/djangoapps/terrain/stubs/tests/test_edxnotes.py index 3a76a875bb..340038b609 100644 --- a/common/djangoapps/terrain/stubs/tests/test_edxnotes.py +++ b/common/djangoapps/terrain/stubs/tests/test_edxnotes.py @@ -34,7 +34,7 @@ class StubEdxNotesServiceTest(unittest.TestCase): """ Returns a list of dummy notes. """ - return [self._get_dummy_note(i) for i in range(count)] # pylint: disable=unused-variable + return [self._get_dummy_note(i) for i in range(count)] def _get_dummy_note(self, uid=0): """ diff --git a/common/djangoapps/third_party_auth/middleware.py b/common/djangoapps/third_party_auth/middleware.py index 836eab3a06..6a94eb9e44 100644 --- a/common/djangoapps/third_party_auth/middleware.py +++ b/common/djangoapps/third_party_auth/middleware.py @@ -1,7 +1,7 @@ """Middleware classes for third_party_auth.""" -import six.moves.urllib.parse # pylint: disable=import-error +import six.moves.urllib.parse from django.contrib import messages from django.shortcuts import redirect from django.urls import reverse diff --git a/common/djangoapps/third_party_auth/models.py b/common/djangoapps/third_party_auth/models.py index 48a29ffa61..1ea6f33fe6 100644 --- a/common/djangoapps/third_party_auth/models.py +++ b/common/djangoapps/third_party_auth/models.py @@ -366,7 +366,7 @@ class OAuth2ProviderConfig(ProviderConfig): help_text=( u'For increased security, you can avoid storing this in your database by leaving ' ' this field blank and setting ' - 'SOCIAL_AUTH_OAUTH_SECRETS = {"(backend name)": "secret", ...} ' # pylint: disable=unicode-format-string + 'SOCIAL_AUTH_OAUTH_SECRETS = {"(backend name)": "secret", ...} ' 'in your instance\'s Django settings (or lms.auth.json)' ) ) @@ -622,9 +622,9 @@ class SAMLProviderConfig(ProviderConfig): verbose_name=u"Advanced settings", blank=True, help_text=( u'For advanced use cases, enter a JSON object with addtional configuration. ' - 'The tpa-saml backend supports {"requiredEntitlements": ["urn:..."]}, ' # pylint: disable=unicode-format-string + 'The tpa-saml backend supports {"requiredEntitlements": ["urn:..."]}, ' 'which can be used to require the presence of a specific eduPersonEntitlement, ' - 'and {"extra_field_definitions": [{"name": "...", "urn": "..."},...]}, which can be ' # pylint: disable=unicode-format-string + 'and {"extra_field_definitions": [{"name": "...", "urn": "..."},...]}, which can be ' 'used to define registration form fields and the URNs that can be used to retrieve ' 'the relevant values from the SAML response. Custom provider types, as selected ' 'in the "Identity Provider Type" field, may make use of the information stored ' @@ -718,7 +718,7 @@ class SAMLProviderConfig(ProviderConfig): data = SAMLProviderData.current(self.entity_id) if not data or not data.is_valid(): log.error( - 'No SAMLProviderData found for provider "%s" with entity id "%s" and IdP slug "%s". ' # pylint: disable=unicode-format-string + 'No SAMLProviderData found for provider "%s" with entity id "%s" and IdP slug "%s". ' 'Run "manage.py saml pull" to fix or debug.', self.name, self.entity_id, self.slug ) @@ -833,7 +833,7 @@ class LTIProviderConfig(ProviderConfig): 'tool consumer instance should know this value. ' 'For increased security, you can avoid storing this in ' 'your database by leaving this field blank and setting ' - 'SOCIAL_AUTH_LTI_CONSUMER_SECRETS = {"consumer key": "secret", ...} ' # pylint: disable=unicode-format-string + 'SOCIAL_AUTH_LTI_CONSUMER_SECRETS = {"consumer key": "secret", ...} ' 'in your instance\'s Django setttigs (or lms.auth.json)' ), blank=True, diff --git a/common/djangoapps/third_party_auth/tests/specs/test_testshib.py b/common/djangoapps/third_party_auth/tests/specs/test_testshib.py index 26e362b806..a4a154f822 100644 --- a/common/djangoapps/third_party_auth/tests/specs/test_testshib.py +++ b/common/djangoapps/third_party_auth/tests/specs/test_testshib.py @@ -463,7 +463,7 @@ class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTes Mock an error response when calling the OData API for user details. """ - def callback(request, uri, headers): # pylint: disable=unused-argument + def callback(request, uri, headers): """ Return a 500 error when someone tries to call the URL. """ diff --git a/common/djangoapps/third_party_auth/tests/test_views.py b/common/djangoapps/third_party_auth/tests/test_views.py index 2f2687db88..7bc3248161 100644 --- a/common/djangoapps/third_party_auth/tests/test_views.py +++ b/common/djangoapps/third_party_auth/tests/test_views.py @@ -56,8 +56,8 @@ class SAMLMetadataTest(SAMLTestCase): self.enable_saml( other_config_str=( '{' - '"TECHNICAL_CONTACT": {"givenName": "Jane Tech", "emailAddress": "jane@example.com"},' # pylint: disable=unicode-format-string - '"SUPPORT_CONTACT": {"givenName": "Joe Support", "emailAddress": "joe@example.com"}' # pylint: disable=unicode-format-string + '"TECHNICAL_CONTACT": {"givenName": "Jane Tech", "emailAddress": "jane@example.com"},' + '"SUPPORT_CONTACT": {"givenName": "Joe Support", "emailAddress": "joe@example.com"}' '}' ) ) diff --git a/common/djangoapps/track/tests/test_contexts.py b/common/djangoapps/track/tests/test_contexts.py index 4c633b3612..c1fad8838c 100644 --- a/common/djangoapps/track/tests/test_contexts.py +++ b/common/djangoapps/track/tests/test_contexts.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - from unittest import TestCase import ddt diff --git a/common/djangoapps/track/tests/test_middleware.py b/common/djangoapps/track/tests/test_middleware.py index 3f3b823b04..7de0cda2f7 100644 --- a/common/djangoapps/track/tests/test_middleware.py +++ b/common/djangoapps/track/tests/test_middleware.py @@ -45,8 +45,7 @@ class TrackMiddlewareTestCase(TestCase): When HTTP headers contains latin1 characters. """ request = self.request_factory.get('/somewhere') - # pylint: disable=no-member - request.META[meta_key] = 'test latin1 \xd3 \xe9 \xf1' # pylint: disable=no-member + request.META[meta_key] = 'test latin1 \xd3 \xe9 \xf1' context = self.get_context_for_request(request) self.assertEqual(context[context_key], u'test latin1 Ó é ñ') diff --git a/common/djangoapps/track/views/tests/test_views.py b/common/djangoapps/track/views/tests/test_views.py index 44cb9e0ffb..5d3ac838d4 100644 --- a/common/djangoapps/track/views/tests/test_views.py +++ b/common/djangoapps/track/views/tests/test_views.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring,maybe-no-member - - import ddt import six from django.contrib.auth.models import User diff --git a/common/djangoapps/util/cache.py b/common/djangoapps/util/cache.py index a082212246..083638dca4 100644 --- a/common/djangoapps/util/cache.py +++ b/common/djangoapps/util/cache.py @@ -72,7 +72,7 @@ def cache_if_anonymous(*get_parameters): get_parameter: six.text_type(parameter_value).encode('utf-8') }) - response = cache.get(cache_key) # pylint: disable=maybe-no-member + response = cache.get(cache_key) if response: # A hack to ensure that the response data is a valid text type for both Python 2 and 3. @@ -82,7 +82,7 @@ def cache_if_anonymous(*get_parameters): response.write(item) else: response = view_func(request, *args, **kwargs) - cache.set(cache_key, response, 60 * 3) # pylint: disable=maybe-no-member + cache.set(cache_key, response, 60 * 3) return response diff --git a/common/djangoapps/util/file.py b/common/djangoapps/util/file.py index ac0ab235be..5ee3f958df 100644 --- a/common/djangoapps/util/file.py +++ b/common/djangoapps/util/file.py @@ -88,7 +88,6 @@ def store_uploaded_file( return file_storage, stored_file_name -# pylint: disable=invalid-name def course_filename_prefix_generator(course_id, separator='_'): """ Generates a course-identifying unicode string for use in a file @@ -103,7 +102,6 @@ def course_filename_prefix_generator(course_id, separator='_'): return get_valid_filename(six.text_type(separator).join([course_id.org, course_id.course, course_id.run])) -# pylint: disable=invalid-name def course_and_time_based_filename_generator(course_id, base_name): """ Generates a filename (without extension) based on the current time and the supplied filename. diff --git a/common/djangoapps/util/milestones_helpers.py b/common/djangoapps/util/milestones_helpers.py index 7e3f3a451e..5ce13c674a 100644 --- a/common/djangoapps/util/milestones_helpers.py +++ b/common/djangoapps/util/milestones_helpers.py @@ -1,4 +1,3 @@ -# pylint: disable=invalid-name """ Utility library for working with the edx-milestones app """ @@ -107,7 +106,7 @@ def set_prerequisite_courses(course_key, prerequisite_course_keys): add_prerequisite_course(course_key, prerequisite_course_key) -def get_pre_requisite_courses_not_completed(user, enrolled_courses): # pylint: disable=invalid-name +def get_pre_requisite_courses_not_completed(user, enrolled_courses): """ Makes a dict mapping courses to their unfulfilled milestones using the fulfillment API of the milestones app. diff --git a/common/djangoapps/util/model_utils.py b/common/djangoapps/util/model_utils.py index f6a33f4ef5..66e9237498 100644 --- a/common/djangoapps/util/model_utils.py +++ b/common/djangoapps/util/model_utils.py @@ -42,7 +42,7 @@ def get_changed_fields_dict(instance, model_class): else: # We want to compare all of the scalar fields on the model, but none of # the relations. - field_names = [f.name for f in model_class._meta.get_fields() if not f.is_relation] # pylint: disable=protected-access + field_names = [f.name for f in model_class._meta.get_fields() if not f.is_relation] changed_fields = { field_name: getattr(old_model, field_name) for field_name in field_names if getattr(old_model, field_name) != getattr(instance, field_name) diff --git a/common/djangoapps/util/module_utils.py b/common/djangoapps/util/module_utils.py index 9ed3e84f70..bb51521a89 100644 --- a/common/djangoapps/util/module_utils.py +++ b/common/djangoapps/util/module_utils.py @@ -3,7 +3,7 @@ Utility library containing operations used/shared by multiple courseware modules """ -def yield_dynamic_descriptor_descendants(descriptor, user_id, module_creator=None): # pylint: disable=invalid-name +def yield_dynamic_descriptor_descendants(descriptor, user_id, module_creator=None): """ This returns all of the descendants of a descriptor. If the descriptor has dynamic children, the module will be created using module_creator diff --git a/common/djangoapps/util/testing.py b/common/djangoapps/util/testing.py index 33169cf90c..3218f51708 100644 --- a/common/djangoapps/util/testing.py +++ b/common/djangoapps/util/testing.py @@ -15,7 +15,7 @@ from mock import patch from util.db import OuterAtomic if six.PY3: - from importlib import reload # pylint: disable=no-name-in-module,redefined-builtin + from importlib import reload class UrlResetMixin(object): diff --git a/common/djangoapps/util/tests/test_date_utils.py b/common/djangoapps/util/tests/test_date_utils.py index e0e0ef66d3..8e42299d69 100644 --- a/common/djangoapps/util/tests/test_date_utils.py +++ b/common/djangoapps/util/tests/test_date_utils.py @@ -102,7 +102,7 @@ def fake_ugettext(translations): """ Create a fake implementation of ugettext, for testing. """ - def _ugettext(text): # pylint: disable=missing-docstring + def _ugettext(text): return translations.get(text, text) return _ugettext @@ -111,7 +111,7 @@ def fake_pgettext(translations): """ Create a fake implementation of pgettext, for testing. """ - def _pgettext(context, text): # pylint: disable=missing-docstring + def _pgettext(context, text): return translations.get((context, text), text) return _pgettext diff --git a/common/djangoapps/util/url.py b/common/djangoapps/util/url.py index b9ea4c3c19..1240791cd1 100644 --- a/common/djangoapps/util/url.py +++ b/common/djangoapps/util/url.py @@ -11,7 +11,7 @@ from django.conf import settings from django.urls import set_urlconf if six.PY3: - from importlib import reload # pylint: disable=no-name-in-module,redefined-builtin + from importlib import reload def reload_django_url_config(): diff --git a/common/djangoapps/util/views.py b/common/djangoapps/util/views.py index a3e0078436..a11e17da61 100644 --- a/common/djangoapps/util/views.py +++ b/common/djangoapps/util/views.py @@ -55,7 +55,7 @@ def ensure_valid_usage_key(view_func): If usage_key_string is not valid raise 404. """ @wraps(view_func) - def inner(request, *args, **kwargs): # pylint: disable=missing-docstring + def inner(request, *args, **kwargs): usage_key = kwargs.get('usage_key_string') if usage_key is not None: try: @@ -72,7 +72,7 @@ def ensure_valid_usage_key(view_func): def require_global_staff(func): """View decorator that requires that the user have global staff permissions. """ @wraps(func) - def wrapped(request, *args, **kwargs): # pylint: disable=missing-docstring + def wrapped(request, *args, **kwargs): if GlobalStaff().has_user(request.user): return func(request, *args, **kwargs) else: @@ -171,8 +171,7 @@ def calculate(request): def info(request): - ''' Info page (link from main header) ''' - # pylint: disable=unused-argument + """ Info page (link from main header) """ return render_to_response("info.html", {}) diff --git a/common/lib/capa/capa/capa_problem.py b/common/lib/capa/capa/capa_problem.py index 5eb1e5e3ed..a3354b47c6 100644 --- a/common/lib/capa/capa/capa_problem.py +++ b/common/lib/capa/capa/capa_problem.py @@ -95,20 +95,20 @@ class LoncapaSystem(object): See :class:`ModuleSystem` for documentation of other attributes. """ - def __init__( # pylint: disable=invalid-name + def __init__( self, ajax_url, anonymous_student_id, cache, can_execute_unsafe_code, get_python_lib_zip, - DEBUG, # pylint: disable=invalid-name + DEBUG, filestore, i18n, node_path, render_template, seed, # Why do we do this if we have self.seed? - STATIC_URL, # pylint: disable=invalid-name + STATIC_URL, xqueue, matlab_api_key=None ): diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 38479f4b77..e6bf7a9763 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -8,7 +8,6 @@ of a variety of types. Used by capa_problem.py """ -# pylint: disable=attribute-defined-outside-init # standard library imports diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index 2b918d462a..50370a9586 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -57,11 +57,12 @@ class ResponseTest(unittest.TestCase): if self.xml_factory_class: self.xml_factory = self.xml_factory_class() - def build_problem(self, capa_system=None, **kwargs): # pylint: disable=missing-docstring + def build_problem(self, capa_system=None, **kwargs): xml = self.xml_factory.build_xml(**kwargs) return new_loncapa_problem(xml, capa_system=capa_system) - def assert_grade(self, problem, submission, expected_correctness, msg=None): # pylint: disable=missing-docstring + # pylint: disable=missing-function-docstring + def assert_grade(self, problem, submission, expected_correctness, msg=None): input_dict = {'1_2_1': submission} correct_map = problem.grade_answers(input_dict) if msg is None: @@ -69,11 +70,12 @@ class ResponseTest(unittest.TestCase): else: self.assertEqual(correct_map.get_correctness('1_2_1'), expected_correctness, msg) - def assert_answer_format(self, problem): # pylint: disable=missing-docstring + def assert_answer_format(self, problem): answers = problem.get_question_answers() self.assertIsNotNone(answers['1_2_1']) - def assert_multiple_grade(self, problem, correct_answers, incorrect_answers): # pylint: disable=missing-docstring + # pylint: disable=missing-function-docstring + def assert_multiple_grade(self, problem, correct_answers, incorrect_answers): for input_str in correct_answers: result = problem.grade_answers({'1_2_1': input_str}).get_correctness('1_2_1') self.assertEqual(result, 'correct') @@ -109,7 +111,7 @@ class ResponseTest(unittest.TestCase): return str(rand.randint(0, 1e9)) -class MultiChoiceResponseTest(ResponseTest): # pylint: disable=missing-docstring +class MultiChoiceResponseTest(ResponseTest): # pylint: disable=missing-class-docstring xml_factory_class = MultipleChoiceResponseXMLFactory def test_multiple_choice_grade(self): @@ -199,7 +201,7 @@ class MultiChoiceResponseTest(ResponseTest): # pylint: disable=missing-docstrin self.assert_grade(problem, 'choice_infinity may be both ... (should be partial)', 'partially-correct') -class TrueFalseResponseTest(ResponseTest): # pylint: disable=missing-docstring +class TrueFalseResponseTest(ResponseTest): # pylint: disable=missing-class-docstring xml_factory_class = TrueFalseResponseXMLFactory def test_true_false_grade(self): @@ -243,7 +245,7 @@ class TrueFalseResponseTest(ResponseTest): # pylint: disable=missing-docstring self.assert_grade(problem, ['choice_0'], 'correct') -class ImageResponseTest(ResponseTest): # pylint: disable=missing-docstring +class ImageResponseTest(ResponseTest): # pylint: disable=missing-class-docstring xml_factory_class = ImageResponseXMLFactory def test_rectangle_grade(self): @@ -306,7 +308,7 @@ class ImageResponseTest(ResponseTest): # pylint: disable=missing-docstring self.assert_answer_format(problem) -class SymbolicResponseTest(ResponseTest): # pylint: disable=missing-docstring +class SymbolicResponseTest(ResponseTest): # pylint: disable=missing-class-docstring xml_factory_class = SymbolicResponseXMLFactory def test_grade_single_input_incorrect(self): @@ -378,7 +380,7 @@ class SymbolicResponseTest(ResponseTest): # pylint: disable=missing-docstring ) -class OptionResponseTest(ResponseTest): # pylint: disable=missing-docstring +class OptionResponseTest(ResponseTest): # pylint: disable=missing-class-docstring xml_factory_class = OptionResponseXMLFactory def test_grade(self): @@ -576,7 +578,7 @@ class FormulaResponseTest(ResponseTest): self.assertFalse(list(problem.responders.values())[0].validate_answer('3*y+2*x')) -class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring +class StringResponseTest(ResponseTest): # pylint: disable=missing-class-docstring xml_factory_class = StringResponseXMLFactory def test_backward_compatibility_for_multiple_answers(self): @@ -938,7 +940,7 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring self.assert_grade(problem, u" ", "incorrect") -class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring +class CodeResponseTest(ResponseTest): # pylint: disable=missing-class-docstring xml_factory_class = CodeResponseXMLFactory def setUp(self): @@ -1129,7 +1131,7 @@ class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring self.assertEqual(output[answer_id]['msg'], u'Invalid grader reply. Please contact the course staff.') -class ChoiceResponseTest(ResponseTest): # pylint: disable=missing-docstring +class ChoiceResponseTest(ResponseTest): # pylint: disable=missing-class-docstring xml_factory_class = ChoiceResponseXMLFactory def test_radio_group_grade(self): @@ -1297,7 +1299,7 @@ class ChoiceResponseTest(ResponseTest): # pylint: disable=missing-docstring self.assert_grade(problem, ['choice_1', 'choice_3'], 'incorrect') -class NumericalResponseTest(ResponseTest): # pylint: disable=missing-docstring +class NumericalResponseTest(ResponseTest): # pylint: disable=missing-class-docstring xml_factory_class = NumericalResponseXMLFactory # We blend the line between integration (using evaluator) and exclusively @@ -1662,7 +1664,7 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-docstring self.assertFalse(responder.validate_answer('fish')) -class CustomResponseTest(ResponseTest): # pylint: disable=missing-docstring +class CustomResponseTest(ResponseTest): # pylint: disable=missing-class-docstring xml_factory_class = CustomResponseXMLFactory def test_inline_code(self): diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 3677b75669..1dbfa7429f 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -35,7 +35,7 @@ from .capa_base import CapaMixin, ComplexEncoder, _ log = logging.getLogger("edx.courseware") -@XBlock.wants('user') # pylint: disable=abstract-method +@XBlock.wants('user') @XBlock.needs('i18n') class ProblemBlock( CapaMixin, RawMixin, XmlMixin, EditingMixin, @@ -203,7 +203,7 @@ class ProblemBlock( self.scope_ids.usage_id, self.scope_ids.user_id ) - _, _, traceback_obj = sys.exc_info() # pylint: disable=redefined-outer-name + _, _, traceback_obj = sys.exc_info() six.reraise(ProcessingError, ProcessingError(not_found_error_message), traceback_obj) except Exception: @@ -213,7 +213,7 @@ class ProblemBlock( self.scope_ids.usage_id, self.scope_ids.user_id ) - _, _, traceback_obj = sys.exc_info() # pylint: disable=redefined-outer-name + _, _, traceback_obj = sys.exc_info() six.reraise(ProcessingError, ProcessingError(generic_error_message), traceback_obj) after = self.get_progress() diff --git a/common/lib/xmodule/xmodule/contentstore/content.py b/common/lib/xmodule/xmodule/contentstore/content.py index 5810a4c0dd..15dd1122dc 100644 --- a/common/lib/xmodule/xmodule/contentstore/content.py +++ b/common/lib/xmodule/xmodule/contentstore/content.py @@ -11,7 +11,7 @@ from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import AssetKey, CourseKey from opaque_keys.edx.locator import AssetLocator from PIL import Image -from six.moves.urllib.parse import parse_qsl, quote_plus, urlencode, urlparse, urlunparse # pylint: disable=import-error +from six.moves.urllib.parse import parse_qsl, quote_plus, urlencode, urlparse, urlunparse from xmodule.assetstore.assetmgr import AssetManager from xmodule.exceptions import NotFoundError @@ -61,7 +61,7 @@ class StaticContent(object): name_root = name_root + ext.replace(u'.', u'-') if dimensions: - width, height = dimensions # pylint: disable=unpacking-non-sequence + width, height = dimensions name_root += "-{}x{}".format(width, height) return u"{name_root}{extension}".format( diff --git a/common/lib/xmodule/xmodule/edxnotes_utils.py b/common/lib/xmodule/xmodule/edxnotes_utils.py index 8da0e83252..c4010bed3c 100644 --- a/common/lib/xmodule/xmodule/edxnotes_utils.py +++ b/common/lib/xmodule/xmodule/edxnotes_utils.py @@ -11,7 +11,7 @@ def edxnotes(cls): Conditional decorator that loads edxnotes only when they exist. """ if "edxnotes" in sys.modules: - from edxnotes.decorators import edxnotes as notes # pylint: disable=import-error + from edxnotes.decorators import edxnotes as notes return notes(cls) else: return cls diff --git a/common/lib/xmodule/xmodule/graders.py b/common/lib/xmodule/xmodule/graders.py index 9a1c15c3ef..503935c181 100644 --- a/common/lib/xmodule/xmodule/graders.py +++ b/common/lib/xmodule/xmodule/graders.py @@ -15,7 +15,7 @@ import six from contracts import contract from pytz import UTC from django.utils.translation import ugettext_lazy as _ -from six.moves import range # pylint: disable=ungrouped-imports +from six.moves import range from xmodule.util.misc import get_short_labeler diff --git a/common/lib/xmodule/xmodule/html_module.py b/common/lib/xmodule/xmodule/html_module.py index 70346486d1..202d9d7e51 100644 --- a/common/lib/xmodule/xmodule/html_module.py +++ b/common/lib/xmodule/xmodule/html_module.py @@ -116,7 +116,6 @@ class HtmlBlock( def get_html(self): """ Returns html required for rendering the block. """ - # pylint: disable=no-member if self.data is not None and getattr(self.system, 'anonymous_student_id', None) is not None: return self.data.replace("%%USER_ID%%", self.system.anonymous_student_id) return self.data @@ -460,7 +459,6 @@ class CourseInfoBlock(CourseInfoFields, HtmlBlock): # When we switch this to an XBlock, we can merge this with student_view, # but for now the XModule mixin requires that this method be defined. - # pylint: disable=no-member if self.data != "": if self.system.anonymous_student_id: return self.data.replace("%%USER_ID%%", self.system.anonymous_student_id) diff --git a/common/lib/xmodule/xmodule/library_content_module.py b/common/lib/xmodule/xmodule/library_content_module.py index b31f5d355c..077d457fce 100644 --- a/common/lib/xmodule/xmodule/library_content_module.py +++ b/common/lib/xmodule/xmodule/library_content_module.py @@ -418,7 +418,7 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe return user_id @XBlock.handler - def refresh_children(self, request=None, suffix=None): # pylint: disable=unused-argument + def refresh_children(self, request=None, suffix=None): """ Refresh children: This method is to be used when any of the libraries that this block @@ -649,7 +649,7 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe for child in self.get_children(): self.runtime.add_block_as_child_node(child, xml_object) # Set node attributes based on our fields. - for field_name, field in six.iteritems(self.fields): # pylint: disable=no-member + for field_name, field in six.iteritems(self.fields): if field_name in ('children', 'parent', 'content'): continue if field.is_set_on(self): diff --git a/common/lib/xmodule/xmodule/lti_2_util.py b/common/lib/xmodule/xmodule/lti_2_util.py index 2fee600dad..f6a389b2e8 100644 --- a/common/lib/xmodule/xmodule/lti_2_util.py +++ b/common/lib/xmodule/xmodule/lti_2_util.py @@ -1,4 +1,3 @@ -# pylint: disable=attribute-defined-outside-init """ A mixin class for LTI 2.0 functionality. This is really just done to refactor the code to keep the LTIModule class from getting too big @@ -156,7 +155,7 @@ class LTI20ModuleMixin(object): log.info("[LTI]: {}".format(msg)) raise LTIError(msg) - def _lti_2_0_result_get_handler(self, request, real_user): # pylint: disable=unused-argument + def _lti_2_0_result_get_handler(self, request, real_user): """ Helper request handler for GET requests to LTI 2.0 result endpoint @@ -182,7 +181,7 @@ class LTI20ModuleMixin(object): base_json_obj['comment'] = self.score_comment return Response(json.dumps(base_json_obj).encode('utf-8'), content_type=LTI_2_0_JSON_CONTENT_TYPE) - def _lti_2_0_result_del_handler(self, request, real_user): # pylint: disable=unused-argument + def _lti_2_0_result_del_handler(self, request, real_user): """ Helper request handler for DELETE requests to LTI 2.0 result endpoint diff --git a/common/lib/xmodule/xmodule/lti_module.py b/common/lib/xmodule/xmodule/lti_module.py index d8cf4b8a2a..fc7a306bd4 100644 --- a/common/lib/xmodule/xmodule/lti_module.py +++ b/common/lib/xmodule/xmodule/lti_module.py @@ -663,7 +663,7 @@ oauth_consumer_key="", oauth_signature="frVp4JuvT1mVXlxktiAUjQ7%2F1cw%3D"'} return params @XBlock.handler - def grade_handler(self, request, suffix): # pylint: disable=unused-argument + def grade_handler(self, request, suffix): """ This is called by courseware.module_render, to handle an AJAX call. diff --git a/common/lib/xmodule/xmodule/modulestore/__init__.py b/common/lib/xmodule/xmodule/modulestore/__init__.py index 785beb9556..00a123e1d1 100644 --- a/common/lib/xmodule/xmodule/modulestore/__init__.py +++ b/common/lib/xmodule/xmodule/modulestore/__init__.py @@ -26,7 +26,7 @@ from xblock.runtime import Mixologist # The below import is not used within this module, but ir is still needed becuase # other modules are imorting EdxJSONEncoder from here -from openedx.core.lib.json_utils import EdxJSONEncoder # pylint: disable=unused-import +from openedx.core.lib.json_utils import EdxJSONEncoder from xmodule.assetstore import AssetMetadata from xmodule.errortracker import make_error_tracker @@ -387,7 +387,7 @@ class EditInfo(object): self.original_usage_version = edit_info.get('original_usage_version', None) def __repr__(self): - # pylint: disable=bad-continuation, redundant-keyword-arg + # pylint: disable=bad-continuation return ("{classname}(previous_version={self.previous_version}, " "update_version={self.update_version}, " "source_version={source_version}, " @@ -474,7 +474,7 @@ class BlockData(object): return self.asides def __repr__(self): - # pylint: disable=bad-continuation, redundant-keyword-arg + # pylint: disable=bad-continuation return ("{classname}(fields={self.fields}, " "block_type={self.block_type}, " "definition={self.definition}, " @@ -1157,11 +1157,9 @@ class ModuleStoreWrite(six.with_metaclass(ABCMeta, ModuleStoreRead, ModuleStoreA # pylint: disable=abstract-method class ModuleStoreReadBase(BulkOperationsMixin, ModuleStoreRead): - ''' + """ Implement interface functionality that can be shared. - ''' - - # pylint: disable=invalid-name + """ def __init__( self, contentstore=None, @@ -1178,7 +1176,6 @@ class ModuleStoreReadBase(BulkOperationsMixin, ModuleStoreRead): ''' super(ModuleStoreReadBase, self).__init__(**kwargs) self._course_errors = defaultdict(make_error_tracker) # location -> ErrorLog - # pylint: disable=fixme # TODO move the inheritance_cache_subsystem to classes which use it self.metadata_inheritance_cache_subsystem = metadata_inheritance_cache_subsystem self.request_cache = request_cache @@ -1194,7 +1191,6 @@ class ModuleStoreReadBase(BulkOperationsMixin, ModuleStoreRead): errors as get_item if course_key isn't present. """ # check that item is present and raise the promised exceptions if needed - # pylint: disable=fixme # TODO (vshnayder): post-launch, make errors properties of items # self.get_item(location) assert isinstance(course_key, CourseKey) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/base.py b/common/lib/xmodule/xmodule/modulestore/mongo/base.py index 2a6a0336d9..2aedf6f1e6 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/base.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/base.py @@ -228,7 +228,7 @@ class CachingDescriptorSystem(MakoDescriptorSystem, EditInfoRuntimeMixin): self.course_id = course_key self.cached_metadata = cached_metadata - def load_item(self, location, for_parent=None): # pylint: disable=method-hidden + def load_item(self, location, for_parent=None): """ Return an XModule instance for the specified location """ @@ -515,7 +515,6 @@ class ParentLocationCache(dict): """ Dict-based object augmented with a more cache-like interface, for internal use. """ - # pylint: disable=missing-docstring @contract(key=six.text_type) def has(self, key): @@ -1653,7 +1652,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo if revision == ModuleStoreEnum.RevisionOption.published_only: query['_id.revision'] = MongoRevisionKey.published - def cache_and_return(parent_loc): # pylint:disable=missing-docstring + def cache_and_return(parent_loc): parent_cache.set(six.text_type(location), parent_loc) return parent_loc diff --git a/common/lib/xmodule/xmodule/modulestore/perf_tests/generate_asset_xml.py b/common/lib/xmodule/xmodule/modulestore/perf_tests/generate_asset_xml.py index 6afcb998d4..ff8bd47cf3 100644 --- a/common/lib/xmodule/xmodule/modulestore/perf_tests/generate_asset_xml.py +++ b/common/lib/xmodule/xmodule/modulestore/perf_tests/generate_asset_xml.py @@ -205,7 +205,6 @@ def validate_xml(xsd_filename, xml_filename): etree.fromstring(f.read(), xmlparser) if click is not None: - # pylint: disable=bad-continuation @click.command() @click.option('--num_assets', type=click.INT, diff --git a/common/lib/xmodule/xmodule/modulestore/perf_tests/generate_report.py b/common/lib/xmodule/xmodule/modulestore/perf_tests/generate_report.py index c5bf859019..6471c004ea 100644 --- a/common/lib/xmodule/xmodule/modulestore/perf_tests/generate_report.py +++ b/common/lib/xmodule/xmodule/modulestore/perf_tests/generate_report.py @@ -50,7 +50,7 @@ class HTMLTable(object): th, td { padding: 5px; }""" - ) # pylint: disable=bad-continuation + ) class HTMLDocument(object): diff --git a/common/lib/xmodule/xmodule/modulestore/perf_tests/test_asset_import_export.py b/common/lib/xmodule/xmodule/modulestore/perf_tests/test_asset_import_export.py index c664220172..f177ac01c8 100644 --- a/common/lib/xmodule/xmodule/modulestore/perf_tests/test_asset_import_export.py +++ b/common/lib/xmodule/xmodule/modulestore/perf_tests/test_asset_import_export.py @@ -37,7 +37,6 @@ ALL_SORTS = ( ('uploadDate', ModuleStoreEnum.SortOrder.descending), ) -# pylint: disable=invalid-name TEST_DIR = path(__file__).dirname() PLATFORM_ROOT = TEST_DIR.parent.parent.parent.parent.parent.parent TEST_DATA_ROOT = PLATFORM_ROOT / TEST_DATA_DIR diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py index c537bc0244..cfa85d27c9 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py @@ -160,7 +160,7 @@ class DraftVersioningModuleStore(SplitMongoModuleStore, ModuleStoreDraftAndPubli descriptor.location = old_descriptor_locn return item - def create_item(self, user_id, course_key, block_type, block_id=None, # pylint: disable=too-many-statements + def create_item(self, user_id, course_key, block_type, block_id=None, # pylint: disable=W0221 definition_locator=None, fields=None, asides=None, force=False, skip_auto_publish=False, **kwargs): """ See :py:meth `ModuleStoreDraftAndPublished.create_item` diff --git a/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py b/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py index 2cc310abe0..1544a69ef3 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py @@ -18,7 +18,7 @@ from mock import patch from six.moves import range from lms.djangoapps.courseware.tests.factories import StaffFactory -from lms.djangoapps.courseware.field_overrides import OverrideFieldData # pylint: disable=import-error +from lms.djangoapps.courseware.field_overrides import OverrideFieldData from openedx.core.djangolib.testing.utils import CacheIsolationMixin, CacheIsolationTestCase, FilteredQueryCountMixin from openedx.core.lib.tempdir import mkdtemp_clean from student.models import CourseEnrollment diff --git a/common/lib/xmodule/xmodule/modulestore/tests/factories.py b/common/lib/xmodule/xmodule/modulestore/tests/factories.py index 9e12e02d29..1d33d9c306 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/factories.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/factories.py @@ -542,7 +542,6 @@ class StackTraceCounter(object): """ stacks = StackTraceCounter(stack_depth, include_arguments) - # pylint: disable=missing-docstring @functools.wraps(func) def capture(*args, **kwargs): stacks.capture_stack(args, kwargs) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/sample_courses.py b/common/lib/xmodule/xmodule/modulestore/tests/sample_courses.py index c2ac366b3d..4a9e027f6e 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/sample_courses.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/sample_courses.py @@ -55,7 +55,12 @@ TOY_BLOCK_INFO_TREE = [ }, [ BlockInfo( "secret:toylab", "html", { - "data": "Lab 2A: Superposition Experiment\n\n\n

Isn't the toy course great?

\n\n

Let's add some markup that uses non-ascii characters.\n'For example, we should be able to write words like encyclopædia, or foreign words like français.\nLooking beyond latin-1, we should handle math symbols: πr² ≤ ∞.\nAnd it shouldn't matter if we use entities or numeric codes — Ω ≠ π ≡ Ω ≠ π.\n

\n\n", # pylint: disable=line-too-long + "data": "Lab 2A: Superposition Experiment\n\n\n

Isn't the toy course great?

\n" + "\n

Let's add some markup that uses non-ascii characters.\n'For example," + " we should be able to write words like encyclopædia, or foreign words like " + "français.\nLooking beyond latin-1, we should handle math symbols: " + " πr² ≤ ∞.\nAnd it shouldn't matter if we use entities or numeric" + " codes — Ω ≠ π ≡ Ω ≠ π.\n

\n\n", "xml_attributes": {"filename": ["html/secret/toylab.xml", "html/secret/toylab.xml"]}, "display_name": "Toy lab" }, [] 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 ba94a058f9..d023e5c99a 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -155,7 +155,6 @@ class CommonMixedModuleStoreSetup(CourseComparisonTest): self.user_id = ModuleStoreEnum.UserID.test - # pylint: disable=invalid-name def _create_course(self, course_key, asides=None): """ Create a course w/ one item in the persistence store using the given course & item location. @@ -249,7 +248,6 @@ class CommonMixedModuleStoreSetup(CourseComparisonTest): """ return self.store.has_changes(self.store.get_item(location)) - # pylint: disable=dangerous-default-value def _initialize_mixed(self, mappings=None, contentstore=None): """ initializes the mixed modulestore. @@ -3571,7 +3569,7 @@ class TestAsidesWithMixedModuleStore(CommonMixedModuleStoreSetup): super(TestAsidesWithMixedModuleStore, self).setUp() key_store = DictKeyValueStore() field_data = KvsFieldData(key_store) - self.runtime = TestRuntime(services={'field-data': field_data}) # pylint: disable=abstract-class-instantiated + self.runtime = TestRuntime(services={'field-data': field_data}) @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @XBlockAside.register_temp_plugin(AsideFoo, 'test_aside1') diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py index 4220f83edf..a381d2f63f 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py @@ -13,7 +13,6 @@ import pymongo import pytest import six -# pylint: disable=no-name-in-module # pylint: disable=bad-continuation # pylint: disable=protected-access from django.test import TestCase diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_semantics.py b/common/lib/xmodule/xmodule/modulestore/tests/test_semantics.py index 98ed3263c1..a8bc3c3554 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_semantics.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_semantics.py @@ -234,7 +234,7 @@ class DirectOnlyCategorySemantics(PureModulestoreTestCase): key_store = DictKeyValueStore() field_data = KvsFieldData(key_store) - aside = AsideTest(scope_ids=scope_ids, runtime=TestRuntime(services={'field-data': field_data})) # pylint: disable=abstract-class-instantiated + aside = AsideTest(scope_ids=scope_ids, runtime=TestRuntime(services={'field-data': field_data})) aside.fields[self.ASIDE_DATA_FIELD.field_name].write_to(aside, self.ASIDE_DATA_FIELD.initial) return [aside] diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py index 788be2a601..1861ef3b82 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py @@ -2278,6 +2278,6 @@ def modulestore(): return SplitModuleTest.modulestore -# pylint: disable=unused-argument, missing-docstring +# pylint: disable=unused-argument def render_to_template_mock(*args): pass diff --git a/common/lib/xmodule/xmodule/modulestore/tests/utils.py b/common/lib/xmodule/xmodule/modulestore/tests/utils.py index 830953c238..91f141d17c 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/utils.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/utils.py @@ -171,9 +171,9 @@ class ProceduralCourseTestMixin(object): Add k chapters, k^2 sections, k^3 verticals, k^4 problems to self.course (where k = branching) """ user_id = self.user.id - self.populated_usage_keys = {} # pylint: disable=attribute-defined-outside-init + self.populated_usage_keys = {} - def descend(parent, stack): # pylint: disable=missing-docstring + def descend(parent, stack): if not stack: return diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index 012fb780e2..8680ea7d9c 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -842,7 +842,7 @@ class XMLModuleStore(ModuleStoreReadBase): return {'xml': True} @contextmanager - def branch_setting(self, branch_setting, course_id=None): # pylint: disable=unused-argument + def branch_setting(self, branch_setting, course_id=None): """ A context manager for temporarily setting the branch value for the store to the given branch_setting. """ diff --git a/common/lib/xmodule/xmodule/modulestore/xml_importer.py b/common/lib/xmodule/xmodule/modulestore/xml_importer.py index 74da12bf13..9e6fdf047d 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_importer.py @@ -689,7 +689,7 @@ class LibraryImportManager(ImportManager): """ Get the descriptor of the library from the XML import modulestore. """ - source_library = self.xml_module_store.get_library(courselike_key) # pylint: disable=no-member + source_library = self.xml_module_store.get_library(courselike_key) library, library_data_path = self.import_courselike( runtime, courselike_key, dest_id, source_library, ) @@ -745,7 +745,7 @@ def _update_and_import_module( """ Move the module to a new course. """ - def _convert_ref_fields_to_new_namespace(reference): # pylint: disable=invalid-name + def _convert_ref_fields_to_new_namespace(reference): """ Convert a reference to the new namespace, but only if the original namespace matched the original course. diff --git a/common/lib/xmodule/xmodule/partitions/partitions.py b/common/lib/xmodule/xmodule/partitions/partitions.py index 891f5a2082..04070cec7e 100644 --- a/common/lib/xmodule/xmodule/partitions/partitions.py +++ b/common/lib/xmodule/xmodule/partitions/partitions.py @@ -126,7 +126,8 @@ class UserPartition(namedtuple("UserPartition", "id name description groups sche # The default scheme to be used when upgrading version 1 partitions. VERSION_1_SCHEME = "random" - def __new__(cls, id, name, description, groups, scheme=None, parameters=None, active=True, scheme_id=VERSION_1_SCHEME): # pylint: disable=line-too-long + def __new__(cls, id, name, description, groups, scheme=None, parameters=None, active=True, + scheme_id=VERSION_1_SCHEME): if not scheme: scheme = UserPartition.get_scheme(scheme_id) if parameters is None: diff --git a/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py b/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py index a21c57da23..f2a57ede35 100644 --- a/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py +++ b/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py @@ -118,7 +118,7 @@ class MockUserPartitionScheme(object): class MockEnrollmentTrackUserPartitionScheme(MockUserPartitionScheme): - def create_user_partition(self, id, name, description, groups=None, parameters=None, active=True): # pylint: disable=redefined-builtin, invalid-name, unused-argument + def create_user_partition(self, id, name, description, groups=None, parameters=None, active=True): # pylint: disable=redefined-builtin, invalid-name """ The EnrollmentTrackPartitionScheme provides this method to return a subclass of UserPartition. """ diff --git a/common/lib/xmodule/xmodule/split_test_module.py b/common/lib/xmodule/xmodule/split_test_module.py index b3c0102bb0..5855e3aeb2 100644 --- a/common/lib/xmodule/xmodule/split_test_module.py +++ b/common/lib/xmodule/xmodule/split_test_module.py @@ -329,7 +329,7 @@ class SplitTestModule(SplitTestFields, XModule, StudioEditableModule): return fragment @XBlock.handler - def log_child_render(self, request, suffix=''): # pylint: disable=unused-argument + def log_child_render(self, request, suffix=''): """ Record in the tracking logs which child was rendered """ @@ -382,9 +382,10 @@ class SplitTestModule(SplitTestFields, XModule, StudioEditableModule): return self.descriptor.validate() -@XBlock.needs('user_tags') # pylint: disable=abstract-method +@XBlock.needs('user_tags') @XBlock.needs('partitions') @XBlock.needs('user') +# pylint: disable=missing-class-docstring class SplitTestDescriptor(SplitTestFields, SequenceDescriptor, StudioEditableDescriptor): # the editing interface can be the same as for sequences -- just a container module_class = SplitTestModule @@ -648,7 +649,7 @@ class SplitTestDescriptor(SplitTestFields, SequenceDescriptor, StudioEditableDes return None @XBlock.handler - def add_missing_groups(self, request, suffix=''): # pylint: disable=unused-argument + def add_missing_groups(self, request, suffix=''): """ Create verticals for any missing groups in the split test instance. diff --git a/common/lib/xmodule/xmodule/tests/__init__.py b/common/lib/xmodule/xmodule/tests/__init__.py index 33cbda76e7..8c2d9fe610 100644 --- a/common/lib/xmodule/xmodule/tests/__init__.py +++ b/common/lib/xmodule/xmodule/tests/__init__.py @@ -47,7 +47,7 @@ class TestModuleSystem(ModuleSystem): # pylint: disable=abstract-method """ ModuleSystem for testing """ - def __init__(self, **kwargs): # pylint: disable=unused-argument + def __init__(self, **kwargs): id_manager = CourseLocationManager(kwargs['course_id']) kwargs.setdefault('id_reader', id_manager) kwargs.setdefault('id_generator', id_manager) @@ -107,7 +107,6 @@ def get_test_system(course_id=CourseKey.from_string('/'.join(['org', 'course', ' def get_module(descriptor): """Mocks module_system get_module function""" - # pylint: disable=protected-access # Unlike XBlock Runtimes or DescriptorSystems, # each XModule is provided with a new ModuleSystem. diff --git a/common/lib/xmodule/xmodule/tests/test_capa_module.py b/common/lib/xmodule/xmodule/tests/test_capa_module.py index f48da0c915..aead4e8808 100644 --- a/common/lib/xmodule/xmodule/tests/test_capa_module.py +++ b/common/lib/xmodule/xmodule/tests/test_capa_module.py @@ -2,7 +2,6 @@ """ Tests of the Capa XModule """ -# pylint: disable=missing-docstring # pylint: disable=invalid-name @@ -861,7 +860,7 @@ class ProblemBlockTest(unittest.TestCase): # pylint: enable=line-too-long self.assertEqual(xqueue_interface._http_post.call_count, 1) - _, kwargs = xqueue_interface._http_post.call_args # pylint: disable=unpacking-non-sequence + _, kwargs = xqueue_interface._http_post.call_args six.assertCountEqual(self, fpaths, list(kwargs['files'].keys())) for fpath, fileobj in six.iteritems(kwargs['files']): self.assertEqual(fpath, fileobj.name) @@ -894,7 +893,7 @@ class ProblemBlockTest(unittest.TestCase): module.handle('xmodule_handler', request, 'problem_check') self.assertEqual(xqueue_interface._http_post.call_count, 1) - _, kwargs = xqueue_interface._http_post.call_args # pylint: disable=unpacking-non-sequence + _, kwargs = xqueue_interface._http_post.call_args six.assertCountEqual(self, fnames, list(kwargs['files'].keys())) for fpath, fileobj in six.iteritems(kwargs['files']): self.assertEqual(fpath, fileobj.name) diff --git a/common/lib/xmodule/xmodule/tests/test_course_metadata_utils.py b/common/lib/xmodule/xmodule/tests/test_course_metadata_utils.py index 5e5e56fdf3..b4dacc2475 100644 --- a/common/lib/xmodule/xmodule/tests/test_course_metadata_utils.py +++ b/common/lib/xmodule/xmodule/tests/test_course_metadata_utils.py @@ -112,8 +112,8 @@ class CourseMetadataUtilsTestCase(TestCase): test_datetime = datetime(1945, 2, 6, 4, 20, 00, tzinfo=utc) advertised_start_parsable = "2038-01-19 03:14:07" - FunctionTest = namedtuple('FunctionTest', 'function scenarios') # pylint: disable=invalid-name - TestScenario = namedtuple('TestScenario', 'arguments expected_return') # pylint: disable=invalid-name + FunctionTest = namedtuple('FunctionTest', 'function scenarios') + TestScenario = namedtuple('TestScenario', 'arguments expected_return') function_tests = [ FunctionTest(clean_course_key, [ diff --git a/common/lib/xmodule/xmodule/tests/test_lti_unit.py b/common/lib/xmodule/xmodule/tests/test_lti_unit.py index ebed5e6cad..0c18c5bea7 100644 --- a/common/lib/xmodule/xmodule/tests/test_lti_unit.py +++ b/common/lib/xmodule/xmodule/tests/test_lti_unit.py @@ -416,7 +416,8 @@ class LTIModuleTest(LogicTest): u'V1.0' u'edX_fix' u'' - u'MITxLTI/MITxLTI/201x:localhost%3A8000-i4x-MITxLTI-MITxLTI-lti-3751833a214a4f66a0d18f63234207f2:363979ef768ca171b50f9d1bfb322131' # pylint: disable=line-too-long + u'MITxLTI/MITxLTI/201x:localhost%3A8000-i4x-MITxLTI-MITxLTI-lti-3751833a214a4f66a0d18f63234207f2' + u':363979ef768ca171b50f9d1bfb322131' u'en0.32' u'' ).encode('utf-8') diff --git a/common/lib/xmodule/xmodule/tests/test_sequence.py b/common/lib/xmodule/xmodule/tests/test_sequence.py index 323d301b5f..cded440e51 100644 --- a/common/lib/xmodule/xmodule/tests/test_sequence.py +++ b/common/lib/xmodule/xmodule/tests/test_sequence.py @@ -88,7 +88,7 @@ class SequenceBlockTestCase(XModuleXmlImportTest): return_value=Mock(vertical_is_complete=Mock(return_value=True)) ) block.xmodule_runtime._services['user'] = StubUserService() # pylint: disable=protected-access - block.xmodule_runtime.xmodule_instance = getattr(block, '_xmodule', None) # pylint: disable=protected-access + block.xmodule_runtime.xmodule_instance = getattr(block, '_xmodule', None) block.parent = parent.location return block diff --git a/common/lib/xmodule/xmodule/tests/test_split_test_module.py b/common/lib/xmodule/xmodule/tests/test_split_test_module.py index 14408c4e6b..4430877067 100644 --- a/common/lib/xmodule/xmodule/tests/test_split_test_module.py +++ b/common/lib/xmodule/xmodule/tests/test_split_test_module.py @@ -72,7 +72,8 @@ class SplitTestModuleTest(XModuleXmlImportTest, PartitionTestCase): parent=sequence, attribs={ 'user_partition_id': '0', - 'group_id_to_child': '{"0": "i4x://edX/xml_test_course/html/split_test_cond0", "1": "i4x://edX/xml_test_course/html/split_test_cond1"}' # pylint: disable=line-too-long + 'group_id_to_child': '{"0": "i4x://edX/xml_test_course/html/split_test_cond0", "1":' + ' "i4x://edX/xml_test_course/html/split_test_cond1"}' } ) xml.HtmlFactory(parent=split_test, url_name='split_test_cond0', text='HTML FOR GROUP 0') diff --git a/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py b/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py index 34b800b3b7..29c5806aaa 100644 --- a/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py +++ b/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py @@ -184,7 +184,6 @@ class LeafDescriptorFactory(Factory): """ Factory to generate leaf XModuleDescriptors. """ - # pylint: disable=missing-docstring class Meta(object): model = XModuleDescriptor @@ -276,7 +275,7 @@ class XBlockWrapperTestMixin(object): """ pass - def check_property(self, descriptor): # pylint: disable=unused-argument + def check_property(self, descriptor): """ Execute assertions to verify that the property under test is true for the supplied descriptor. @@ -306,20 +305,19 @@ class XBlockWrapperTestMixin(object): descriptor_cls, fields = cls_and_fields self.skip_if_invalid(descriptor_cls) descriptor = ContainerModuleFactory(descriptor_cls=descriptor_cls, depth=2, **fields) - # pylint: disable=no-member descriptor.runtime.id_reader.get_definition_id = Mock(return_value='a') self.check_property(descriptor) # Test that when an xmodule is generated from descriptor_cls # with mixed xmodule and xblock children, the test property holds @ddt.data(*flatten(CONTAINER_XMODULES)) - def test_container_node_mixed(self, cls_and_fields): # pylint: disable=unused-argument + def test_container_node_mixed(self, cls_and_fields): raise SkipTest("XBlock support in XDescriptor not yet fully implemented") # Test that when an xmodule is generated from descriptor_cls # with only xblock children, the test property holds @ddt.data(*flatten(CONTAINER_XMODULES)) - def test_container_node_xblocks_only(self, cls_and_fields): # pylint: disable=unused-argument + def test_container_node_xblocks_only(self, cls_and_fields): raise SkipTest("XBlock support in XModules not yet fully implemented") diff --git a/common/lib/xmodule/xmodule/video_module/__init__.py b/common/lib/xmodule/xmodule/video_module/__init__.py index cbee7351b9..8c132b766d 100644 --- a/common/lib/xmodule/xmodule/video_module/__init__.py +++ b/common/lib/xmodule/xmodule/video_module/__init__.py @@ -2,8 +2,6 @@ Container for video module and its utils. """ -# pylint: disable=wildcard-import - from .bumper_utils import * from .transcripts_utils import * from .video_module import * diff --git a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py index 09a14f809f..fca01d7352 100644 --- a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py +++ b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py @@ -19,7 +19,7 @@ from pysrt import SubRipFile, SubRipItem, SubRipTime from pysrt.srtexc import Error from six import text_type from six.moves import range, zip -from six.moves.html_parser import HTMLParser # pylint: disable=import-error +from six.moves.html_parser import HTMLParser from openedx.core.djangolib import blockstore_cache from openedx.core.lib import blockstore_api @@ -40,19 +40,19 @@ log = logging.getLogger(__name__) NON_EXISTENT_TRANSCRIPT = 'non_existent_dummy_file_name' -class TranscriptException(Exception): # pylint: disable=missing-docstring +class TranscriptException(Exception): pass -class TranscriptsGenerationException(Exception): # pylint: disable=missing-docstring +class TranscriptsGenerationException(Exception): pass -class GetTranscriptsFromYouTubeException(Exception): # pylint: disable=missing-docstring +class GetTranscriptsFromYouTubeException(Exception): pass -class TranscriptsRequestValidationException(Exception): # pylint: disable=missing-docstring +class TranscriptsRequestValidationException(Exception): pass diff --git a/common/lib/xmodule/xmodule/video_module/video_module.py b/common/lib/xmodule/xmodule/video_module/video_module.py index 870f2b2e4d..1884a1388c 100644 --- a/common/lib/xmodule/xmodule/video_module/video_module.py +++ b/common/lib/xmodule/xmodule/video_module/video_module.py @@ -821,7 +821,8 @@ class VideoBlock( _ = self.runtime.service(self, "i18n").ugettext video_url.update({ - 'help': _('The URL for your video. This can be a YouTube URL or a link to an .mp4, .ogg, or .webm video file hosted elsewhere on the Internet.'), # pylint: disable=line-too-long + 'help': _('The URL for your video. This can be a YouTube URL or a link to an .mp4, .ogg, or ' + '.webm video file hosted elsewhere on the Internet.'), 'display_name': _('Default Video URL'), 'field_name': 'video_url', 'type': 'VideoList', diff --git a/common/lib/xmodule/xmodule/video_module/video_utils.py b/common/lib/xmodule/xmodule/video_module/video_utils.py index 8b6f0e3bee..19e27d4865 100644 --- a/common/lib/xmodule/xmodule/video_module/video_utils.py +++ b/common/lib/xmodule/xmodule/video_module/video_utils.py @@ -12,7 +12,7 @@ from django.conf import settings from django.core.exceptions import ValidationError from django.core.validators import URLValidator from six.moves import zip -from six.moves.urllib.parse import parse_qs, urlencode, urlparse, urlsplit, urlunsplit # pylint: disable=import-error +from six.moves.urllib.parse import parse_qs, urlencode, urlparse, urlsplit, urlunsplit log = logging.getLogger(__name__) diff --git a/common/lib/xmodule/xmodule/video_module/video_xfields.py b/common/lib/xmodule/xmodule/video_module/video_xfields.py index c18c554649..60f257130b 100644 --- a/common/lib/xmodule/xmodule/video_module/video_xfields.py +++ b/common/lib/xmodule/xmodule/video_module/video_xfields.py @@ -77,24 +77,36 @@ class VideoFields(object): #front-end code of video player checks logical validity of (start_time, end_time) pair. download_video = Boolean( - help=_("Allow students to download versions of this video in different formats if they cannot use the edX video player or do not have access to YouTube. You must add at least one non-YouTube URL in the Video File URLs field."), # pylint: disable=line-too-long + help=_("Allow students to download versions of this video in different formats if they cannot use the edX video" + " player or do not have access to YouTube. You must add at least one non-YouTube URL " + "in the Video File URLs field."), display_name=_("Video Download Allowed"), scope=Scope.settings, default=False ) html5_sources = List( - help=_("The URL or URLs where you've posted non-YouTube versions of the video. Each URL must end in .mpeg, .mp4, .ogg, or .webm and cannot be a YouTube URL. (For browser compatibility, we strongly recommend .mp4 and .webm format.) Students will be able to view the first listed video that's compatible with the student's computer. To allow students to download these videos, set Video Download Allowed to True."), # pylint: disable=line-too-long + help=_("The URL or URLs where you've posted non-YouTube versions of the video. Each URL must end in .mpeg," + " .mp4, .ogg, or .webm and cannot be a YouTube URL. (For browser compatibility, we strongly recommend" + " .mp4 and .webm format.) Students will be able to view the first listed video that's compatible with" + " the student's computer. To allow students to download these videos, " + "set Video Download Allowed to True."), display_name=_("Video File URLs"), scope=Scope.settings, ) track = String( - help=_("By default, students can download an .srt or .txt transcript when you set Download Transcript Allowed to True. If you want to provide a downloadable transcript in a different format, we recommend that you upload a handout by using the Upload a Handout field. If this isn't possible, you can post a transcript file on the Files & Uploads page or on the Internet, and then add the URL for the transcript here. Students see a link to download that transcript below the video."), # pylint: disable=line-too-long + help=_("By default, students can download an .srt or .txt transcript when you set Download Transcript " + "Allowed to True. If you want to provide a downloadable transcript in a different format, we recommend " + "that you upload a handout by using the Upload a Handout field. If this isn't possible, you can post a " + "transcript file on the Files & Uploads page or on the Internet, and then add the URL for the " + "transcript here. Students see a link to download that transcript below the video."), display_name=_("Downloadable Transcript URL"), scope=Scope.settings, default='' ) download_track = Boolean( - help=_("Allow students to download the timed transcript. A link to download the file appears below the video. By default, the transcript is an .srt or .txt file. If you want to provide the transcript for download in a different format, upload a file by using the Upload Handout field."), # pylint: disable=line-too-long + help=_("Allow students to download the timed transcript. A link to download the file appears below the video." + " By default, the transcript is an .srt or .txt file. If you want to provide the transcript for " + "download in a different format, upload a file by using the Upload Handout field."), display_name=_("Download Transcript Allowed"), scope=Scope.settings, default=False @@ -102,7 +114,8 @@ class VideoFields(object): # `sub` is deprecated field and should not be used in future. Now, transcripts are primarily handled in VAL and # backward compatibility for the video modules already using this field has been ensured. sub = String( - help=_("The default transcript for the video, from the Default Timed Transcript field on the Basic tab. This transcript should be in English. You don't have to change this setting."), # pylint: disable=line-too-long + help=_("The default transcript for the video, from the Default Timed Transcript field on the Basic tab. " + "This transcript should be in English. You don't have to change this setting."), display_name=_("Default Timed Transcript"), scope=Scope.settings, default="" @@ -115,7 +128,8 @@ class VideoFields(object): ) # Data format: {'de': 'german_translation', 'uk': 'ukrainian_translation'} transcripts = Dict( - help=_("Add transcripts in different languages. Click below to specify a language and upload an .srt transcript file for that language."), # pylint: disable=line-too-long + help=_("Add transcripts in different languages." + " Click below to specify a language and upload an .srt transcript file for that language."), display_name=_("Transcript Languages"), scope=Scope.settings, default={} @@ -160,7 +174,8 @@ class VideoFields(object): default=True ) handout = String( - help=_("Upload a handout to accompany this video. Students can download the handout by clicking Download Handout under the video."), # pylint: disable=line-too-long + help=_("Upload a handout to accompany this video. Students can download the handout by " + "clicking Download Handout under the video."), display_name=_("Upload Handout"), scope=Scope.settings, ) @@ -174,7 +189,10 @@ class VideoFields(object): default=False ) edx_video_id = String( - help=_("If you were assigned a Video ID by edX for the video to play in this component, enter the ID here. In this case, do not enter values in the Default Video URL, the Video File URLs, and the YouTube ID fields. If you were not assigned a Video ID, enter values in those other fields and ignore this field."), # pylint: disable=line-too-long + help=_("If you were assigned a Video ID by edX for the video to play in this component, enter the ID here." + " In this case, do not enter values in the Default Video URL, the Video File URLs, " + "and the YouTube ID fields. If you were not assigned a Video ID," + " enter values in those other fields and ignore this field."), display_name=_("Video ID"), scope=Scope.settings, default="", diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index 11a94ef42f..308bd90779 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -672,7 +672,6 @@ class XModuleMixin(XModuleFields, XBlock): Note that the functions will be applied in the order in which they're listed. So [f1, f2] -> f2(f1(field_data)) """ - # pylint: disable=attribute-defined-outside-init # Skip rebinding if we're already bound a user, and it's this user. if self.scope_ids.user_id is not None and user_id == self.scope_ids.user_id: @@ -964,7 +963,7 @@ class XModule(XModuleToXBlockMixin, HTMLSnippet, XModuleMixin): return CombinedSystem(self._runtime, self.descriptor._runtime) # pylint: disable=protected-access @runtime.setter - def runtime(self, value): # pylint: disable=arguments-differ + def runtime(self, value): self._runtime = value def __str__(self): @@ -1393,7 +1392,7 @@ class ConfigurableFragmentWrapper(object): # Runtime.handler_url interface. # # The monkey-patching happens in cms/djangoapps/xblock_config/apps.py and lms/djangoapps/lms_xblock/apps.py -def descriptor_global_handler_url(block, handler_name, suffix='', query='', thirdparty=False): # pylint: disable=unused-argument +def descriptor_global_handler_url(block, handler_name, suffix='', query='', thirdparty=False): """ See :meth:`xblock.runtime.Runtime.handler_url`. """ @@ -1405,7 +1404,7 @@ def descriptor_global_handler_url(block, handler_name, suffix='', query='', thir # the Runtime part of its interface. This function matches the Runtime.local_resource_url interface # # The monkey-patching happens in cms/djangoapps/xblock_config/apps.py and lms/djangoapps/lms_xblock/apps.py -def descriptor_global_local_resource_url(block, uri): # pylint: disable=invalid-name, unused-argument +def descriptor_global_local_resource_url(block, uri): """ See :meth:`xblock.runtime.Runtime.local_resource_url`. """ diff --git a/common/test/acceptance/fixtures/config.py b/common/test/acceptance/fixtures/config.py index 0e359bdbc1..ad6152be12 100644 --- a/common/test/acceptance/fixtures/config.py +++ b/common/test/acceptance/fixtures/config.py @@ -90,7 +90,7 @@ class ConfigModelFixture(object): # auto_auth returns information about the newly created user # capture this so it can be used by by the testcases. user_pattern = re.compile( - six.text_type(r'Logged in user {0} \({1}\) with password {2} and user_id {3}').format( # pylint: disable=unicode-format-string + six.text_type(r'Logged in user {0} \({1}\) with password {2} and user_id {3}').format( r'(?P\S+)', r'(?P[^\)]+)', r'(?P\S+)', r'(?P\d+)')) user_matches = re.match(user_pattern, response.text) if user_matches: diff --git a/common/test/acceptance/pages/lms/create_mode.py b/common/test/acceptance/pages/lms/create_mode.py index c2f3f5807f..8c4f2cfe29 100644 --- a/common/test/acceptance/pages/lms/create_mode.py +++ b/common/test/acceptance/pages/lms/create_mode.py @@ -3,7 +3,7 @@ import re -import six.moves.urllib.parse # pylint: disable=import-error +import six.moves.urllib.parse from bok_choy.page_object import PageObject from common.test.acceptance.pages.lms import BASE_URL diff --git a/common/test/acceptance/pages/lms/fields.py b/common/test/acceptance/pages/lms/fields.py index 1237251d6d..28dc541467 100644 --- a/common/test/acceptance/pages/lms/fields.py +++ b/common/test/acceptance/pages/lms/fields.py @@ -70,7 +70,6 @@ class FieldsMixin(object): Return the title of a field. """ self.wait_for_field(field_id) - # pylint: disable=unicode-format-string query = self.q(css=six.u('.u-field-{} .u-field-title').format(field_id)) return query.text[0] if query.present else None @@ -79,7 +78,6 @@ class FieldsMixin(object): Return the current message in a field. """ self.wait_for_field(field_id) - # pylint: disable=unicode-format-string query = self.q(css=six.u('.u-field-{} .u-field-message'.format(field_id))) return query.text[0] if query.present else None @@ -159,7 +157,6 @@ class FieldsMixin(object): Get or set the value of a text field. """ self.wait_for_field(field_id) - # pylint: disable=unicode-format-string query = self.q(css=six.u('.u-field-{} input'.format(field_id))) if not query.present: return None diff --git a/common/test/acceptance/pages/lms/login_and_register.py b/common/test/acceptance/pages/lms/login_and_register.py index d4298507a2..de97aefd1f 100644 --- a/common/test/acceptance/pages/lms/login_and_register.py +++ b/common/test/acceptance/pages/lms/login_and_register.py @@ -3,7 +3,7 @@ from bok_choy.page_object import PageObject, unguarded from bok_choy.promise import EmptyPromise, Promise -from six.moves.urllib.parse import urlencode # pylint: disable=import-error +from six.moves.urllib.parse import urlencode from common.test.acceptance.pages.lms import BASE_URL from common.test.acceptance.pages.lms.dashboard import DashboardPage diff --git a/common/test/acceptance/pages/studio/asset_index.py b/common/test/acceptance/pages/studio/asset_index.py index a757ca4b96..d8f465aaa0 100644 --- a/common/test/acceptance/pages/studio/asset_index.py +++ b/common/test/acceptance/pages/studio/asset_index.py @@ -18,7 +18,6 @@ from common.test.acceptance.pages.studio.course_page import CoursePage # file path found from CourseFixture logic UPLOAD_SUFFIX = '/data/uploads/studio-uploads/' -# pylint: disable=no-value-for-parameter UPLOAD_FILE_DIR = Path(__file__).abspath().dirname().dirname().dirname().dirname() + UPLOAD_SUFFIX diff --git a/common/test/acceptance/pages/studio/import_export.py b/common/test/acceptance/pages/studio/import_export.py index a152b33161..6b2f5f0059 100644 --- a/common/test/acceptance/pages/studio/import_export.py +++ b/common/test/acceptance/pages/studio/import_export.py @@ -68,7 +68,7 @@ class ImportExportMixin(object): """ string = self.q(css='.item-progresspoint-success-date').text[0] - return re.match(six.text_type(r'\(([^ ]+).+?(\d{2}:\d{2})'), string).groups() # pylint: disable=unicode-format-string + return re.match(six.text_type(r'\(([^ ]+).+?(\d{2}:\d{2})'), string).groups() def wait_for_tasks(self, completed=False, fail_on=None): """ diff --git a/common/test/acceptance/pages/studio/textbook_upload.py b/common/test/acceptance/pages/studio/textbook_upload.py index 56c29464d1..c730e8b3b8 100644 --- a/common/test/acceptance/pages/studio/textbook_upload.py +++ b/common/test/acceptance/pages/studio/textbook_upload.py @@ -43,7 +43,7 @@ class TextbookUploadPage(CoursePage): Uploads a pdf textbook. """ # If the pdf upload section has not yet been toggled on, click on the upload pdf button - test_dir = path(__file__).abspath().dirname().dirname().dirname().dirname() # pylint:disable=no-value-for-parameter + test_dir = path(__file__).abspath().dirname().dirname().dirname().dirname() file_path = test_dir + '/data/uploads/' + file_name click_css(self, ".edit-textbook .action-upload", require_notification=False) diff --git a/common/test/acceptance/tests/discussion/test_discussion.py b/common/test/acceptance/tests/discussion/test_discussion.py index 0be1f78ff4..d3923fa980 100644 --- a/common/test/acceptance/tests/discussion/test_discussion.py +++ b/common/test/acceptance/tests/discussion/test_discussion.py @@ -1032,7 +1032,7 @@ class DiscussionEditorPreviewTest(UniqueCourseTest): self.page.set_new_post_editor_value( six.text_type( r'\begin{equation}' - r'\tau_g(\omega) = - \frac{d}{d\omega}\phi(\omega) \hspace{2em} (1) ' # pylint: disable=unicode-format-string + r'\tau_g(\omega) = - \frac{d}{d\omega}\phi(\omega) \hspace{2em} (1) ' r'\end{equation}' ) ) diff --git a/common/test/acceptance/tests/helpers.py b/common/test/acceptance/tests/helpers.py index 9323b9b3d0..6ccb438a36 100644 --- a/common/test/acceptance/tests/helpers.py +++ b/common/test/acceptance/tests/helpers.py @@ -112,7 +112,7 @@ def load_data_str(rel_path): Load a file from the "data" directory as a string. `rel_path` is the path relative to the data directory. """ - full_path = path(__file__).abspath().dirname() / "data" / rel_path # pylint: disable=no-value-for-parameter + full_path = path(__file__).abspath().dirname() / "data" / rel_path with open(full_path) as data_file: return data_file.read() diff --git a/common/test/acceptance/tests/lms/test_lms_dashboard.py b/common/test/acceptance/tests/lms/test_lms_dashboard.py index 8b0790dc4e..5982148a65 100644 --- a/common/test/acceptance/tests/lms/test_lms_dashboard.py +++ b/common/test/acceptance/tests/lms/test_lms_dashboard.py @@ -7,7 +7,7 @@ End-to-end tests for the main LMS Dashboard (aka, Student Dashboard). import datetime import re import six -from six.moves.urllib.parse import unquote # pylint: disable=import-error +from six.moves.urllib.parse import unquote from common.test.acceptance.fixtures.course import CourseFixture, XBlockFixtureDesc from common.test.acceptance.pages.common.auto_auth import AutoAuthPage from common.test.acceptance.pages.lms.course_home import CourseHomePage diff --git a/common/test/acceptance/tests/lms/test_progress_page.py b/common/test/acceptance/tests/lms/test_progress_page.py index eef12c4fd8..5744800cff 100644 --- a/common/test/acceptance/tests/lms/test_progress_page.py +++ b/common/test/acceptance/tests/lms/test_progress_page.py @@ -346,7 +346,7 @@ class SubsectionGradingPolicyA11yTest(SubsectionGradingPolicyBase): # Verify that y-Axis labels are aria-hidden self.assertEqual(['100%', 'true'], self.progress_page.y_tick_label(0)) self.assertEqual(['0%', 'true'], self.progress_page.y_tick_label(1)) - self.assertEqual(['Pass 50%', 'true'], self.progress_page.y_tick_label(2)) # pylint: disable=unicode-format-string + self.assertEqual(['Pass 50%', 'true'], self.progress_page.y_tick_label(2)) # Verify x-Axis labels and sr-text self._check_tick_text(0, [u'Homework 1 - Test Subsection 1 - 50% (1/2)'], u'HW 01') @@ -407,7 +407,7 @@ class SubsectionGradingPolicyA11yTest(SubsectionGradingPolicyBase): # Verify the overall score. The first element in the array is the sr-only text, and the # second is the total text (including the sr-only text). - self.assertEqual(['Overall Score', 'Overall Score\n2%'], self.progress_page.graph_overall_score()) # pylint: disable=unicode-format-string + self.assertEqual(['Overall Score', 'Overall Score\n2%'], self.progress_page.graph_overall_score()) class ProgressPageA11yTest(ProgressPageBaseTest): diff --git a/lms/djangoapps/badges/apps.py b/lms/djangoapps/badges/apps.py index 97f299e8b7..f637ba7c60 100644 --- a/lms/djangoapps/badges/apps.py +++ b/lms/djangoapps/badges/apps.py @@ -18,4 +18,4 @@ class BadgesConfig(AppConfig): """ Connect signal handlers. """ - from . import handlers # pylint: disable=unused-variable + from . import handlers # pylint: disable=unused-import diff --git a/lms/djangoapps/branding/api.py b/lms/djangoapps/branding/api.py index a9aa9ea18b..651a868a23 100644 --- a/lms/djangoapps/branding/api.py +++ b/lms/djangoapps/branding/api.py @@ -495,7 +495,7 @@ def _absolute_url(is_secure, url_path): """ site_name = configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME) parts = ("https" if is_secure else "http", site_name, url_path, '', '', '') - return six.moves.urllib.parse.urlunparse(parts) # pylint: disable=too-many-function-args + return six.moves.urllib.parse.urlunparse(parts) def _absolute_url_staticfile(is_secure, name): diff --git a/lms/djangoapps/bulk_email/signals.py b/lms/djangoapps/bulk_email/signals.py index 8a48acd0e2..319110d04f 100644 --- a/lms/djangoapps/bulk_email/signals.py +++ b/lms/djangoapps/bulk_email/signals.py @@ -12,7 +12,7 @@ from .models import Optout @receiver(USER_RETIRE_MAILINGS) -def force_optout_all(sender, **kwargs): # pylint: disable=unused-argument +def force_optout_all(sender, **kwargs): """ When a user is retired from all mailings this method will create an Optout row for any courses they may be enrolled in. diff --git a/lms/djangoapps/ccx/api/v0/tests/test_views.py b/lms/djangoapps/ccx/api/v0/tests/test_views.py index 95f08f655d..77e3d74c77 100644 --- a/lms/djangoapps/ccx/api/v0/tests/test_views.py +++ b/lms/djangoapps/ccx/api/v0/tests/test_views.py @@ -11,9 +11,6 @@ from datetime import timedelta import ddt import mock import six -import six.moves.urllib.error # pylint: disable=import-error -import six.moves.urllib.parse # pylint: disable=import-error -import six.moves.urllib.request # pylint: disable=import-error from ccx_keys.locator import CCXLocator from django.conf import settings from django.contrib.auth.models import User @@ -25,12 +22,12 @@ from rest_framework import status from rest_framework.test import APITestCase from six.moves import range, zip -from lms.djangoapps.courseware import courses from lms.djangoapps.ccx.api.v0 import views from lms.djangoapps.ccx.models import CcxFieldOverride, CustomCourseForEdX from lms.djangoapps.ccx.overrides import override_field_for_ccx from lms.djangoapps.ccx.tests.utils import CcxTestCase from lms.djangoapps.ccx.utils import ccx_course as ccx_course_cm +from lms.djangoapps.courseware import courses from lms.djangoapps.instructor.access import allow_access, list_with_level from lms.djangoapps.instructor.enrollment import enroll_email, get_email_params from student.models import CourseEnrollment @@ -911,7 +908,7 @@ class CcxDetailTest(CcxRestApiTest): resp.data.get('max_students_allowed'), self.ccx.max_student_enrollments_allowed ) - self.assertEqual(resp.data.get('coach_email'), self.ccx.coach.email) # pylint: disable=no-member + self.assertEqual(resp.data.get('coach_email'), self.ccx.coach.email) self.assertEqual(resp.data.get('master_course_id'), six.text_type(self.ccx.course_id)) six.assertCountEqual(self, resp.data.get('course_modules'), self.master_course_chapters) @@ -994,7 +991,7 @@ class CcxDetailTest(CcxRestApiTest): """ display_name = self.ccx.display_name max_students_allowed = self.ccx.max_student_enrollments_allowed - coach_email = self.ccx.coach.email # pylint: disable=no-member + coach_email = self.ccx.coach.email ccx_structure = self.ccx.structure resp = self.client.patch(self.detail_url, {}, format='json', HTTP_AUTHORIZATION=self.auth) self.assertEqual(resp.status_code, status.HTTP_204_NO_CONTENT) diff --git a/lms/djangoapps/ccx/api/v0/views.py b/lms/djangoapps/ccx/api/v0/views.py index a261498932..cecf7aa235 100644 --- a/lms/djangoapps/ccx/api/v0/views.py +++ b/lms/djangoapps/ccx/api/v0/views.py @@ -648,7 +648,7 @@ class CCXDetailView(GenericAPIView): serializer = self.get_serializer(ccx_course_object) return Response(serializer.data) - def delete(self, request, ccx_course_id=None): # pylint: disable=unused-argument + def delete(self, request, ccx_course_id=None): """ Deletes a CCX course. diff --git a/lms/djangoapps/ccx/tests/factories.py b/lms/djangoapps/ccx/tests/factories.py index 97f39616e2..dc3ce3fa7c 100644 --- a/lms/djangoapps/ccx/tests/factories.py +++ b/lms/djangoapps/ccx/tests/factories.py @@ -10,7 +10,8 @@ from lms.djangoapps.ccx.models import CustomCourseForEdX from student.tests.factories import UserFactory -class CcxFactory(DjangoModelFactory): # pylint: disable=missing-docstring +# pylint: disable=missing-class-docstring +class CcxFactory(DjangoModelFactory): class Meta(object): model = CustomCourseForEdX diff --git a/lms/djangoapps/ccx/tests/test_views.py b/lms/djangoapps/ccx/tests/test_views.py index ec7373edc0..b9db00e178 100644 --- a/lms/djangoapps/ccx/tests/test_views.py +++ b/lms/djangoapps/ccx/tests/test_views.py @@ -9,7 +9,6 @@ import re import ddt import six -import six.moves.urllib.parse # pylint: disable=import-error from six.moves import range, zip from ccx_keys.locator import CCXLocator from django.conf import settings @@ -631,7 +630,7 @@ class TestCoachDashboard(CcxTestCase, LoginEnrollmentTestCase): ) data = { button_tuple[0]: button_tuple[1], - student_form_input_name: u','.join([student.email, ]), # pylint: disable=no-member + student_form_input_name: u','.join([student.email, ]), } if send_email: data['email-students'] = 'Notify-students-by-email' @@ -642,7 +641,7 @@ class TestCoachDashboard(CcxTestCase, LoginEnrollmentTestCase): self.assertIn(302, response.redirect_chain[0]) self.assertEqual(len(outbox), outbox_count) if send_email: - self.assertIn(student.email, outbox[0].recipients()) # pylint: disable=no-member + self.assertIn(student.email, outbox[0].recipients()) # a CcxMembership exists for this student self.assertTrue( CourseEnrollment.objects.filter(course_id=self.course.id, user=student).exists() @@ -727,7 +726,7 @@ class TestCoachDashboard(CcxTestCase, LoginEnrollmentTestCase): ) data = { button_tuple[0]: button_tuple[1], - student_form_input_name: u','.join([student.email, ]), # pylint: disable=no-member + student_form_input_name: u','.join([student.email, ]), } if send_email: data['email-students'] = 'Notify-students-by-email' @@ -738,7 +737,7 @@ class TestCoachDashboard(CcxTestCase, LoginEnrollmentTestCase): self.assertIn(302, response.redirect_chain[0]) self.assertEqual(len(outbox), outbox_count) if send_email: - self.assertIn(student.email, outbox[0].recipients()) # pylint: disable=no-member + self.assertIn(student.email, outbox[0].recipients()) # a CcxMembership does not exists for this student self.assertFalse( CourseEnrollment.objects.filter(course_id=self.course.id, user=student).exists() diff --git a/lms/djangoapps/ccx/views.py b/lms/djangoapps/ccx/views.py index 85f22f869f..768e967bf4 100644 --- a/lms/djangoapps/ccx/views.py +++ b/lms/djangoapps/ccx/views.py @@ -446,7 +446,7 @@ def get_ccx_schedule(course, ccx): @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) @coach_dashboard -def ccx_schedule(request, course, ccx=None): # pylint: disable=unused-argument +def ccx_schedule(request, course, ccx=None): """ get json representation of ccx schedule """ diff --git a/lms/djangoapps/certificates/api.py b/lms/djangoapps/certificates/api.py index 365a2ef957..65858c7aaa 100644 --- a/lms/djangoapps/certificates/api.py +++ b/lms/djangoapps/certificates/api.py @@ -148,7 +148,7 @@ def get_recently_modified_certificates(course_keys=None, start_date=None, end_da if end_date: cert_filter_args['modified_date__lte'] = end_date - return GeneratedCertificate.objects.filter(**cert_filter_args).order_by('modified_date') # pylint: disable=no-member + return GeneratedCertificate.objects.filter(**cert_filter_args).order_by('modified_date') def generate_user_certificates(student, course_key, course=None, insecure=False, generation_mode='batch', diff --git a/lms/djangoapps/certificates/apps.py b/lms/djangoapps/certificates/apps.py index d259b088ab..7150a864cb 100644 --- a/lms/djangoapps/certificates/apps.py +++ b/lms/djangoapps/certificates/apps.py @@ -22,7 +22,7 @@ class CertificatesConfig(AppConfig): """ # Can't import models at module level in AppConfigs, and models get # included from the signal handlers - from . import signals # pylint: disable=unused-variable + from . import signals # pylint: disable=unused-import if settings.FEATURES.get('ENABLE_SPECIAL_EXAMS'): from .services import CertificateService set_runtime_service('certificates', CertificateService()) diff --git a/lms/djangoapps/certificates/management/commands/fix_ungraded_certs.py b/lms/djangoapps/certificates/management/commands/fix_ungraded_certs.py index 664b47069d..a687b39fe9 100644 --- a/lms/djangoapps/certificates/management/commands/fix_ungraded_certs.py +++ b/lms/djangoapps/certificates/management/commands/fix_ungraded_certs.py @@ -45,7 +45,7 @@ class Command(BaseCommand): def handle(self, *args, **options): course_id = options['course'] log.info(u'Fetching ungraded students for %s.', course_id) - ungraded = GeneratedCertificate.objects.filter( # pylint: disable=no-member + ungraded = GeneratedCertificate.objects.filter( course_id__exact=course_id ).filter(grade__exact='') course = courses.get_course_by_id(course_id) diff --git a/lms/djangoapps/certificates/management/commands/gen_cert_report.py b/lms/djangoapps/certificates/management/commands/gen_cert_report.py index 80550b8397..5750504e57 100644 --- a/lms/djangoapps/certificates/management/commands/gen_cert_report.py +++ b/lms/djangoapps/certificates/management/commands/gen_cert_report.py @@ -65,15 +65,15 @@ class Command(BaseCommand): enrolled_total = User.objects.filter( courseenrollment__course_id=course_id ) - verified_enrolled = GeneratedCertificate.objects.filter( # pylint: disable=no-member + verified_enrolled = GeneratedCertificate.objects.filter( course_id__exact=course_id, mode__exact='verified' ) - honor_enrolled = GeneratedCertificate.objects.filter( # pylint: disable=no-member + honor_enrolled = GeneratedCertificate.objects.filter( course_id__exact=course_id, mode__exact='honor' ) - audit_enrolled = GeneratedCertificate.objects.filter( # pylint: disable=no-member + audit_enrolled = GeneratedCertificate.objects.filter( course_id__exact=course_id, mode__exact='audit' ) @@ -86,7 +86,7 @@ class Command(BaseCommand): 'audit_enrolled': audit_enrolled.count() } - status_tally = GeneratedCertificate.objects.filter( # pylint: disable=no-member + status_tally = GeneratedCertificate.objects.filter( course_id__exact=course_id ).values('status').annotate( dcount=Count('status') @@ -98,7 +98,7 @@ class Command(BaseCommand): } ) - mode_tally = GeneratedCertificate.objects.filter( # pylint: disable=no-member + mode_tally = GeneratedCertificate.objects.filter( course_id__exact=course_id, status__exact='downloadable' ).values('mode').annotate( diff --git a/lms/djangoapps/certificates/management/commands/resubmit_error_certificates.py b/lms/djangoapps/certificates/management/commands/resubmit_error_certificates.py index 609db7f0f8..c142157fff 100644 --- a/lms/djangoapps/certificates/management/commands/resubmit_error_certificates.py +++ b/lms/djangoapps/certificates/management/commands/resubmit_error_certificates.py @@ -84,7 +84,7 @@ class Command(BaseCommand): # Retrieve the IDs of generated certificates with # error status in the set of courses we're considering. queryset = ( - GeneratedCertificate.objects.select_related('user') # pylint: disable=no-member + GeneratedCertificate.objects.select_related('user') ).filter(status=CertificateStatuses.error) if only_course_keys: queryset = queryset.filter(course_id__in=only_course_keys) diff --git a/lms/djangoapps/certificates/models.py b/lms/djangoapps/certificates/models.py index 71639b1510..9a40eaf81c 100644 --- a/lms/djangoapps/certificates/models.py +++ b/lms/djangoapps/certificates/models.py @@ -319,7 +319,7 @@ class GeneratedCertificate(models.Model): return { cert.course_id for cert - in cls.objects.filter(user=user).only('course_id') # pylint: disable=no-member + in cls.objects.filter(user=user).only('course_id') } @classmethod diff --git a/lms/djangoapps/certificates/queue.py b/lms/djangoapps/certificates/queue.py index 07632f65a8..6abf5ecce9 100644 --- a/lms/djangoapps/certificates/queue.py +++ b/lms/djangoapps/certificates/queue.py @@ -332,7 +332,6 @@ class XQueueCertInterface(object): mode_is_verified, generate_pdf ) - # pylint: disable=no-member cert, created = GeneratedCertificate.objects.get_or_create(user=student, course_id=course_id) cert.mode = cert_mode diff --git a/lms/djangoapps/certificates/tests/factories.py b/lms/djangoapps/certificates/tests/factories.py index 0fd4c148ca..61df9af239 100644 --- a/lms/djangoapps/certificates/tests/factories.py +++ b/lms/djangoapps/certificates/tests/factories.py @@ -1,5 +1,4 @@ # Factories are self documenting -# pylint: disable=missing-docstring from uuid import uuid4 diff --git a/lms/djangoapps/certificates/tests/test_models.py b/lms/djangoapps/certificates/tests/test_models.py index 5a43e5b0ca..f68260da6c 100644 --- a/lms/djangoapps/certificates/tests/test_models.py +++ b/lms/djangoapps/certificates/tests/test_models.py @@ -33,7 +33,6 @@ from xmodule.modulestore.tests.factories import CourseFactory FEATURES_INVALID_FILE_PATH = settings.FEATURES.copy() FEATURES_INVALID_FILE_PATH['CERTS_HTML_VIEW_CONFIG_PATH'] = 'invalid/path/to/config.json' -# pylint: disable=invalid-name TEST_DIR = path(__file__).dirname() TEST_DATA_DIR = 'common/test/data/' PLATFORM_ROOT = TEST_DIR.parent.parent.parent.parent diff --git a/lms/djangoapps/certificates/tests/test_webview_views.py b/lms/djangoapps/certificates/tests/test_webview_views.py index c6d86d3282..d28c51aa52 100644 --- a/lms/djangoapps/certificates/tests/test_webview_views.py +++ b/lms/djangoapps/certificates/tests/test_webview_views.py @@ -15,7 +15,7 @@ from django.test.utils import override_settings from django.urls import reverse from mock import patch from six.moves import range -from six.moves.urllib.parse import urlencode # pylint: disable=import-error +from six.moves.urllib.parse import urlencode from course_modes.models import CourseMode from lms.djangoapps.badges.events.course_complete import get_completion_badge diff --git a/lms/djangoapps/certificates/views/support.py b/lms/djangoapps/certificates/views/support.py index d0fb0911eb..01b75f3630 100644 --- a/lms/djangoapps/certificates/views/support.py +++ b/lms/djangoapps/certificates/views/support.py @@ -89,7 +89,6 @@ def search_certificates(request): ] """ - # pylint: disable=too-many-function-args unbleached_filter = six.moves.urllib.parse.unquote(six.moves.urllib.parse.quote_plus(request.GET.get("user", ""))) user_filter = bleach.clean(unbleached_filter) if not user_filter: @@ -108,7 +107,6 @@ def search_certificates(request): cert["modified"] = cert["modified"].isoformat() cert["regenerate"] = not cert['is_pdf_certificate'] - # pylint: disable=redundant-keyword-arg course_id = six.moves.urllib.parse.quote_plus(request.GET.get("course_id", ""), safe=':/') if course_id: try: diff --git a/lms/djangoapps/commerce/apps.py b/lms/djangoapps/commerce/apps.py index 9c0c217ccc..9e94283d69 100644 --- a/lms/djangoapps/commerce/apps.py +++ b/lms/djangoapps/commerce/apps.py @@ -16,4 +16,4 @@ class CommerceConfig(AppConfig): """ Connect handlers to signals. """ - from . import signals # pylint: disable=unused-variable + from . import signals # pylint: disable=unused-import diff --git a/lms/djangoapps/commerce/tests/mocks.py b/lms/djangoapps/commerce/tests/mocks.py index 7b41f09bc2..4b0813f992 100644 --- a/lms/djangoapps/commerce/tests/mocks.py +++ b/lms/djangoapps/commerce/tests/mocks.py @@ -60,9 +60,9 @@ class mock_ecommerce_api_endpoint(object): """ raise NotImplementedError - def _exception_body(self, request, uri, headers): # pylint: disable=unused-argument + def _exception_body(self, request, uri, headers): """Helper used to create callbacks in order to have httpretty raise Exceptions.""" - raise self.exception # pylint: disable=raising-bad-type + raise self.exception def __enter__(self): httpretty.enable() diff --git a/lms/djangoapps/commerce/tests/test_signals.py b/lms/djangoapps/commerce/tests/test_signals.py index 473bcd6eb1..0917c94e12 100644 --- a/lms/djangoapps/commerce/tests/test_signals.py +++ b/lms/djangoapps/commerce/tests/test_signals.py @@ -16,7 +16,7 @@ from django.test import TestCase from django.test.utils import override_settings from opaque_keys.edx.keys import CourseKey from requests import Timeout -from six.moves.urllib.parse import urljoin # pylint: disable=import-error +from six.moves.urllib.parse import urljoin from course_modes.models import CourseMode from student.signals import REFUND_ORDER diff --git a/lms/djangoapps/commerce/tests/test_utils.py b/lms/djangoapps/commerce/tests/test_utils.py index 6e3b688c65..45f4283b9f 100644 --- a/lms/djangoapps/commerce/tests/test_utils.py +++ b/lms/djangoapps/commerce/tests/test_utils.py @@ -11,7 +11,7 @@ from django.test.client import RequestFactory from django.test.utils import override_settings from mock import patch from opaque_keys.edx.locator import CourseLocator -from six.moves.urllib.parse import urlencode # pylint: disable=import-error +from six.moves.urllib.parse import urlencode from waffle.testutils import override_switch from course_modes.models import CourseMode diff --git a/lms/djangoapps/commerce/utils.py b/lms/djangoapps/commerce/utils.py index e82f469603..7901b1662c 100644 --- a/lms/djangoapps/commerce/utils.py +++ b/lms/djangoapps/commerce/utils.py @@ -12,7 +12,7 @@ from django.contrib.auth import get_user_model from django.urls import reverse from django.utils.translation import ugettext as _ from opaque_keys.edx.keys import CourseKey -from six.moves.urllib.parse import urlencode, urljoin # pylint: disable=import-error +from six.moves.urllib.parse import urlencode, urljoin from course_modes.models import CourseMode from openedx.core.djangoapps.commerce.utils import ecommerce_api_client, is_commerce_service_configured diff --git a/lms/djangoapps/course_api/blocks/tests/test_forms.py b/lms/djangoapps/course_api/blocks/tests/test_forms.py index 826f8c3259..62a8692b4f 100644 --- a/lms/djangoapps/course_api/blocks/tests/test_forms.py +++ b/lms/djangoapps/course_api/blocks/tests/test_forms.py @@ -5,7 +5,7 @@ Tests for Course Blocks forms import ddt import six -from six.moves.urllib.parse import urlencode # pylint: disable=import-error +from six.moves.urllib.parse import urlencode from django.http import Http404, QueryDict from opaque_keys.edx.locator import CourseLocator from rest_framework.exceptions import PermissionDenied diff --git a/lms/djangoapps/course_api/blocks/tests/test_views.py b/lms/djangoapps/course_api/blocks/tests/test_views.py index 7435f6ba96..99061b2cd7 100644 --- a/lms/djangoapps/course_api/blocks/tests/test_views.py +++ b/lms/djangoapps/course_api/blocks/tests/test_views.py @@ -6,7 +6,7 @@ Tests for Blocks Views from datetime import datetime import six -from six.moves.urllib.parse import urlencode, urlunparse # pylint: disable=import-error +from six.moves.urllib.parse import urlencode, urlunparse from django.urls import reverse from opaque_keys.edx.locator import CourseLocator diff --git a/lms/djangoapps/course_api/serializers.py b/lms/djangoapps/course_api/serializers.py index 69fa5c33ff..931fbe83f8 100644 --- a/lms/djangoapps/course_api/serializers.py +++ b/lms/djangoapps/course_api/serializers.py @@ -3,9 +3,9 @@ Course API Serializers. Representing course catalog data """ -import six.moves.urllib.error # pylint: disable=import-error -import six.moves.urllib.parse # pylint: disable=import-error -import six.moves.urllib.request # pylint: disable=import-error +import six.moves.urllib.error +import six.moves.urllib.parse +import six.moves.urllib.request from django.urls import reverse from rest_framework import serializers diff --git a/lms/djangoapps/course_api/tests/test_forms.py b/lms/djangoapps/course_api/tests/test_forms.py index ed2c2e0951..1ecaa48ebd 100644 --- a/lms/djangoapps/course_api/tests/test_forms.py +++ b/lms/djangoapps/course_api/tests/test_forms.py @@ -1,13 +1,12 @@ """ Tests for Course API forms. """ -# pylint: disable=missing-docstring from itertools import product import ddt import six -from six.moves.urllib.parse import urlencode # pylint: disable=import-error +from six.moves.urllib.parse import urlencode from django.contrib.auth.models import AnonymousUser from django.http import QueryDict diff --git a/lms/djangoapps/course_goals/apps.py b/lms/djangoapps/course_goals/apps.py index 3e700224b2..fb41462d11 100644 --- a/lms/djangoapps/course_goals/apps.py +++ b/lms/djangoapps/course_goals/apps.py @@ -18,4 +18,4 @@ class CourseGoalsConfig(AppConfig): """ Connect signal handlers. """ - from . import handlers # pylint: disable=unused-variable + from . import handlers # pylint: disable=unused-import diff --git a/lms/djangoapps/course_wiki/editors.py b/lms/djangoapps/course_wiki/editors.py index 8dcd4ee822..c289df47b4 100644 --- a/lms/djangoapps/course_wiki/editors.py +++ b/lms/djangoapps/course_wiki/editors.py @@ -57,7 +57,7 @@ class CodeMirror(BaseEditor): def get_widget(self, instance=None): return CodeMirrorWidget() - class AdminMedia(object): # pylint: disable=missing-docstring + class AdminMedia(object): # pylint: disable=missing-class-docstring css = { 'all': ("wiki/markitup/skins/simple/style.css", "wiki/markitup/sets/admin/style.css",) diff --git a/lms/djangoapps/course_wiki/middleware.py b/lms/djangoapps/course_wiki/middleware.py index 5463e6f4f1..828103a00f 100644 --- a/lms/djangoapps/course_wiki/middleware.py +++ b/lms/djangoapps/course_wiki/middleware.py @@ -7,7 +7,7 @@ from django.http import Http404 from django.shortcuts import redirect from django.utils.deprecation import MiddlewareMixin from six import text_type -from six.moves.urllib.parse import urlparse # pylint: disable=import-error +from six.moves.urllib.parse import urlparse from wiki.models import reverse from lms.djangoapps.courseware.access import has_access @@ -40,7 +40,7 @@ class WikiAccessMiddleware(MiddlewareMixin): # Even though we came from the course, we can't see it. So don't worry about it. pass - def process_view(self, request, view_func, view_args, view_kwargs): # pylint: disable=unused-argument + def process_view(self, request, view_func, view_args, view_kwargs): """ This function handles authentication logic for wiki urls and redirects from the "root wiki" to the "course wiki" if the user accesses the wiki from a course url diff --git a/lms/djangoapps/course_wiki/views.py b/lms/djangoapps/course_wiki/views.py index 4c0d005afe..b484fdfb4d 100644 --- a/lms/djangoapps/course_wiki/views.py +++ b/lms/djangoapps/course_wiki/views.py @@ -22,7 +22,7 @@ from openedx.features.enterprise_support.api import data_sharing_consent_require log = logging.getLogger(__name__) -def root_create(request): # pylint: disable=unused-argument +def root_create(request): """ In the edX wiki, we don't show the root_create view. Instead, we just create the root automatically if it doesn't exist. @@ -32,7 +32,7 @@ def root_create(request): # pylint: disable=unused-argument @data_sharing_consent_required -def course_wiki_redirect(request, course_id, wiki_path=""): # pylint: disable=unused-argument +def course_wiki_redirect(request, course_id, wiki_path=""): """ This redirects to whatever page on the wiki that the course designates as it's home page. A course's wiki must be an article on the root (for diff --git a/lms/djangoapps/courseware/__init__.py b/lms/djangoapps/courseware/__init__.py index 548417e4a1..e2cad60414 100644 --- a/lms/djangoapps/courseware/__init__.py +++ b/lms/djangoapps/courseware/__init__.py @@ -1,10 +1,6 @@ -#pylint: disable=missing-docstring - - import warnings if __name__ == 'courseware': - # pylint: disable=unicode-format-string # Show the call stack that imported us wrong. msg = "Importing 'lms.djangoapps.courseware' as 'courseware' is no longer supported" warnings.warn(msg, DeprecationWarning) diff --git a/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py b/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py index 1de9a61a47..cc341f3b24 100644 --- a/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py +++ b/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py @@ -188,7 +188,7 @@ class CommandsTestBase(SharedModuleStoreTestCase): dumped_id = dump[text_type(discussion_key)]['metadata']['discussion_id'] self.assertEqual(dumped_id, "custom") - def check_export_file(self, tar_file): # pylint: disable=missing-docstring + def check_export_file(self, tar_file): # pylint: disable=missing-function-docstring names = tar_file.getnames() # Check if some of the files are present. diff --git a/lms/djangoapps/courseware/tests/factories.py b/lms/djangoapps/courseware/tests/factories.py index cbf28521ec..4e0cafada1 100644 --- a/lms/djangoapps/courseware/tests/factories.py +++ b/lms/djangoapps/courseware/tests/factories.py @@ -1,5 +1,4 @@ # Factories are self documenting -# pylint: disable=missing-docstring import json diff --git a/lms/djangoapps/courseware/tests/helpers.py b/lms/djangoapps/courseware/tests/helpers.py index 4a7d86e865..00f0e9ca97 100644 --- a/lms/djangoapps/courseware/tests/helpers.py +++ b/lms/djangoapps/courseware/tests/helpers.py @@ -413,7 +413,7 @@ def get_context_dict_from_string(data): Retrieve dictionary from string. """ # Replace tuple and un-necessary info from inside string and get the dictionary. - cleaned_data = ast.literal_eval(data.split('((\'video.html\',')[1].replace("),\n {})", '').strip()) # pylint: disable=unicode-format-string + cleaned_data = ast.literal_eval(data.split('((\'video.html\',')[1].replace("),\n {})", '').strip()) cleaned_data['metadata'] = OrderedDict( sorted(json.loads(cleaned_data['metadata']).items(), key=lambda t: t[0]) ) diff --git a/lms/djangoapps/courseware/tests/test_field_overrides.py b/lms/djangoapps/courseware/tests/test_field_overrides.py index 05375e8a71..237ba3d03b 100644 --- a/lms/djangoapps/courseware/tests/test_field_overrides.py +++ b/lms/djangoapps/courseware/tests/test_field_overrides.py @@ -1,9 +1,6 @@ """ Tests for `field_overrides` module. """ -# pylint: disable=missing-docstring - - import unittest from django.test.utils import override_settings diff --git a/lms/djangoapps/courseware/tests/test_i18n.py b/lms/djangoapps/courseware/tests/test_i18n.py index 64bbbd6371..31e3318015 100644 --- a/lms/djangoapps/courseware/tests/test_i18n.py +++ b/lms/djangoapps/courseware/tests/test_i18n.py @@ -36,7 +36,7 @@ class BaseI18nTestCase(CacheIsolationTestCase): def assert_tag_has_attr(self, content, tag, attname, value): """Assert that a tag in `content` has a certain value in a certain attribute.""" - regex_string = six.text_type(r"""<{tag} [^>]*\b{attname}=['"]([\w\d\- ]+)['"][^>]*>""") # noqa: W605,E501 pylint: disable=unicode-format-string + regex_string = six.text_type(r"""<{tag} [^>]*\b{attname}=['"]([\w\d\- ]+)['"][^>]*>""") # noqa: W605,E501 regex = regex_string.format(tag=tag, attname=attname) match = re.search(regex, content) self.assertTrue(match, u"Couldn't find desired tag '%s' with attr '%s' in %r" % (tag, attname, content)) diff --git a/lms/djangoapps/courseware/tests/test_lti_integration.py b/lms/djangoapps/courseware/tests/test_lti_integration.py index 1d79e800d2..1a6dc83f13 100644 --- a/lms/djangoapps/courseware/tests/test_lti_integration.py +++ b/lms/djangoapps/courseware/tests/test_lti_integration.py @@ -6,9 +6,7 @@ from collections import OrderedDict import mock import oauthlib -import six.moves.urllib.error # pylint: disable=import-error -import six.moves.urllib.parse # pylint: disable=import-error -import six.moves.urllib.request # pylint: disable=import-error +import six from django.conf import settings from django.urls import reverse from six import text_type diff --git a/lms/djangoapps/courseware/tests/test_self_paced_overrides.py b/lms/djangoapps/courseware/tests/test_self_paced_overrides.py index c230dcb1d6..d70ace2ca1 100644 --- a/lms/djangoapps/courseware/tests/test_self_paced_overrides.py +++ b/lms/djangoapps/courseware/tests/test_self_paced_overrides.py @@ -1,6 +1,4 @@ """Tests for self-paced course due date overrides.""" -# pylint: disable=missing-docstring - import datetime diff --git a/lms/djangoapps/courseware/tests/test_services.py b/lms/djangoapps/courseware/tests/test_services.py index 50281ad89a..47ec2bff45 100644 --- a/lms/djangoapps/courseware/tests/test_services.py +++ b/lms/djangoapps/courseware/tests/test_services.py @@ -96,7 +96,8 @@ class TestUserStateService(ModuleStoreTestCase): @ddt.data( *itertools.product( [ - ({'username_or_email': 'no_user', 'block_id': 'block-v1:myOrg+123+2030_T2+type@openassessment+block@hash'}), # pylint: disable=line-too-long + ({'username_or_email': 'no_user', 'block_id': + 'block-v1:myOrg+123+2030_T2+type@openassessment+block@hash'}), ({'username_or_email': 'no_user'}), ({'block_id': 'block-v1:myOrg+1234+2030_T2+type@openassessment+block@hash'}) ], [ diff --git a/lms/djangoapps/courseware/tests/test_video_mongo.py b/lms/djangoapps/courseware/tests/test_video_mongo.py index 2c8b9b47fa..7f6955c6b6 100644 --- a/lms/djangoapps/courseware/tests/test_video_mongo.py +++ b/lms/djangoapps/courseware/tests/test_video_mongo.py @@ -1326,7 +1326,6 @@ class TestEditorSavedMethod(BaseTestVideoXBlock): } # path to subs_3_yD_cEKoCk.srt.sjson file self.file_name = 'subs_3_yD_cEKoCk.srt.sjson' - # pylint: disable=no-value-for-parameter self.test_dir = path(__file__).abspath().dirname().dirname().dirname().dirname().dirname() self.file_path = self.test_dir + '/common/test/data/uploads/' + self.file_name diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index beb50b5fe8..10101001c2 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -31,8 +31,8 @@ from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator from pytz import UTC from six import text_type from six.moves import range -from six.moves.html_parser import HTMLParser # pylint: disable=import-error -from six.moves.urllib.parse import quote, urlencode # pylint: disable=import-error +from six.moves.html_parser import HTMLParser +from six.moves.urllib.parse import quote, urlencode from web_fragments.fragment import Fragment from xblock.core import XBlock from xblock.fields import Scope, String diff --git a/lms/djangoapps/courseware/testutils.py b/lms/djangoapps/courseware/testutils.py index b4a2f371d0..a7613585eb 100644 --- a/lms/djangoapps/courseware/testutils.py +++ b/lms/djangoapps/courseware/testutils.py @@ -9,7 +9,7 @@ from datetime import datetime, timedelta import ddt import six from mock import patch -from six.moves.urllib.parse import urlencode # pylint: disable=import-error +from six.moves.urllib.parse import urlencode from lms.djangoapps.courseware.field_overrides import OverrideModulestoreFieldData from lms.djangoapps.courseware.url_helpers import get_redirect_url diff --git a/lms/djangoapps/courseware/url_helpers.py b/lms/djangoapps/courseware/url_helpers.py index eb0e06fd79..ed5c358a61 100644 --- a/lms/djangoapps/courseware/url_helpers.py +++ b/lms/djangoapps/courseware/url_helpers.py @@ -6,7 +6,7 @@ Module to define url helpers functions import six from django.conf import settings from django.urls import reverse -from six.moves.urllib.parse import urlencode # pylint: disable=import-error +from six.moves.urllib.parse import urlencode from xmodule.modulestore.django import modulestore from xmodule.modulestore.search import navigation_index, path_to_location diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py index 123e63368b..0630cd6907 100644 --- a/lms/djangoapps/courseware/views/index.py +++ b/lms/djangoapps/courseware/views/index.py @@ -8,10 +8,7 @@ View for Courseware Index import logging import six -import six.moves.urllib as urllib # pylint: disable=import-error -import six.moves.urllib.error # pylint: disable=import-error -import six.moves.urllib.parse # pylint: disable=import-error -import six.moves.urllib.request # pylint: disable=import-error +from six.moves import urllib from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth.views import redirect_to_login diff --git a/lms/djangoapps/courseware/views/views.py b/lms/djangoapps/courseware/views/views.py index bae747368e..b963ba4fed 100644 --- a/lms/djangoapps/courseware/views/views.py +++ b/lms/djangoapps/courseware/views/views.py @@ -5,15 +5,12 @@ Courseware views functions import json import logging -import requests -from requests.exceptions import Timeout, ConnectionError from collections import OrderedDict, namedtuple from datetime import datetime import bleach -import six.moves.urllib.error # pylint: disable=import-error -import six.moves.urllib.parse # pylint: disable=import-error -import six.moves.urllib.request # pylint: disable=import-error +import requests +import six from django.conf import settings from django.contrib.auth.decorators import login_required from django.contrib.auth.models import AnonymousUser, User @@ -37,12 +34,12 @@ from django.views.decorators.http import require_GET, require_http_methods, requ from django.views.generic import View from edx_django_utils import monitoring as monitoring_utils from edx_django_utils.monitoring import set_custom_metrics_for_course_key -from edxnotes.helpers import is_feature_enabled from ipware.ip import get_ip from markupsafe import escape from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey, UsageKey from pytz import UTC +from requests.exceptions import ConnectionError, Timeout # pylint: disable=redefined-builtin from rest_framework import status from rest_framework.decorators import api_view, throttle_classes from rest_framework.response import Response @@ -53,8 +50,14 @@ from web_fragments.fragment import Fragment import shoppingcart import survey.views from course_modes.models import CourseMode, get_course_prices +from edxmako.shortcuts import marketing_link, render_to_response, render_to_string +from edxnotes.helpers import is_feature_enabled +from lms.djangoapps.ccx.custom_exception import CCXLocatorValidationException +from lms.djangoapps.certificates import api as certs_api +from lms.djangoapps.certificates.models import CertificateStatuses +from lms.djangoapps.commerce.utils import EcommerceService from lms.djangoapps.courseware.access import has_access, has_ccx_coach_role -from lms.djangoapps.courseware.access_utils import check_course_open_for_learner +from lms.djangoapps.courseware.access_utils import check_course_open_for_learner, check_public_access from lms.djangoapps.courseware.courses import ( can_self_enroll_in_course, course_open_for_self_enrollment, @@ -70,21 +73,18 @@ from lms.djangoapps.courseware.courses import ( sort_by_start_date ) from lms.djangoapps.courseware.date_summary import verified_upgrade_deadline_link +from lms.djangoapps.courseware.exceptions import CourseAccessRedirect, Redirect from lms.djangoapps.courseware.masquerade import setup_masquerade from lms.djangoapps.courseware.model_data import FieldDataCache from lms.djangoapps.courseware.models import BaseStudentModuleHistory, StudentModule from lms.djangoapps.courseware.permissions import ( - MASQUERADE_AS_STUDENT, VIEW_COURSE_HOME, VIEW_COURSEWARE, VIEW_XQA_INTERFACE, + MASQUERADE_AS_STUDENT, + VIEW_COURSE_HOME, + VIEW_COURSEWARE, + VIEW_XQA_INTERFACE ) from lms.djangoapps.courseware.url_helpers import get_redirect_url from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateClient -from edxmako.shortcuts import marketing_link, render_to_response, render_to_string -from lms.djangoapps.ccx.custom_exception import CCXLocatorValidationException -from lms.djangoapps.certificates import api as certs_api -from lms.djangoapps.certificates.models import CertificateStatuses -from lms.djangoapps.commerce.utils import EcommerceService -from lms.djangoapps.courseware.access_utils import check_public_access -from lms.djangoapps.courseware.exceptions import CourseAccessRedirect, Redirect from lms.djangoapps.experiments.utils import get_experiment_user_metadata_context from lms.djangoapps.grades.api import CourseGradeFactory from lms.djangoapps.instructor.enrollment import uses_shib @@ -111,9 +111,9 @@ from openedx.core.djangolib.markup import HTML, Text from openedx.features.course_duration_limits.access import generate_course_expired_fragment from openedx.features.course_experience import ( COURSE_ENABLE_UNENROLLED_ACCESS_FLAG, - UNIFIED_COURSE_TAB_FLAG, - course_home_url_name, RELATIVE_DATES_FLAG, + UNIFIED_COURSE_TAB_FLAG, + course_home_url_name ) from openedx.features.course_experience.course_tools import CourseToolsPluginManager from openedx.features.course_experience.utils import reset_deadlines_banner_should_display @@ -866,7 +866,7 @@ class EnrollStaffView(View): Either enrolls the user in course or redirects user to course about page depending upon the option (Enroll, Don't Enroll) chosen by the user. """ - _next = six.moves.urllib.parse.quote_plus(request.GET.get('next', 'info'), safe='/:?=') # pylint: disable=redundant-keyword-arg + _next = six.moves.urllib.parse.quote_plus(request.GET.get('next', 'info'), safe='/:?=') course_key = CourseKey.from_string(course_id) enroll = 'enroll' in request.POST if enroll: diff --git a/lms/djangoapps/discussion/apps.py b/lms/djangoapps/discussion/apps.py index cc75cdb876..edb82d5174 100644 --- a/lms/djangoapps/discussion/apps.py +++ b/lms/djangoapps/discussion/apps.py @@ -39,4 +39,4 @@ class DiscussionConfig(AppConfig): """ Connect handlers to send notifications about discussions. """ - from .signals import handlers # pylint: disable=unused-variable + from .signals import handlers # pylint: disable=unused-import diff --git a/lms/djangoapps/discussion/django_comment_client/base/__init__.py b/lms/djangoapps/discussion/django_comment_client/base/__init__.py index 6fb9c4756b..ce2d4e380c 100644 --- a/lms/djangoapps/discussion/django_comment_client/base/__init__.py +++ b/lms/djangoapps/discussion/django_comment_client/base/__init__.py @@ -1,5 +1,3 @@ -# pylint: disable=missing-docstring # This import registers the ForumThreadViewedEventTransformer - from . import event_transformers diff --git a/lms/djangoapps/discussion/django_comment_client/base/views.py b/lms/djangoapps/discussion/django_comment_client/base/views.py index c28065d275..505cda2841 100644 --- a/lms/djangoapps/discussion/django_comment_client/base/views.py +++ b/lms/djangoapps/discussion/django_comment_client/base/views.py @@ -1,4 +1,3 @@ -# pylint: disable=missing-docstring,unused-argument """Views for discussion forums.""" @@ -10,7 +9,6 @@ import time import eventtracking import six -import six.moves.urllib.parse # pylint: disable=import-error from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from django.core import exceptions @@ -783,7 +781,7 @@ def upload(request, course_id): # ajax upload file to a question or answer result = _('Good') file_url = file_storage.url(new_file_name) parsed_url = six.moves.urllib.parse.urlparse(file_url) - file_url = six.moves.urllib.parse.urlunparse( # pylint: disable=too-many-function-args + file_url = six.moves.urllib.parse.urlunparse( six.moves.urllib.parse.ParseResult( parsed_url.scheme, parsed_url.netloc, diff --git a/lms/djangoapps/discussion/django_comment_client/middleware.py b/lms/djangoapps/discussion/django_comment_client/middleware.py index fd76a9060e..300a3f1111 100644 --- a/lms/djangoapps/discussion/django_comment_client/middleware.py +++ b/lms/djangoapps/discussion/django_comment_client/middleware.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - import json import logging diff --git a/lms/djangoapps/discussion/django_comment_client/permissions.py b/lms/djangoapps/discussion/django_comment_client/permissions.py index ca346e94bb..99fd8e6a05 100644 --- a/lms/djangoapps/discussion/django_comment_client/permissions.py +++ b/lms/djangoapps/discussion/django_comment_client/permissions.py @@ -1,4 +1,3 @@ -# pylint: disable=missing-docstring """ Module for checking permissions with the comment_client backend """ diff --git a/lms/djangoapps/discussion/django_comment_client/settings.py b/lms/djangoapps/discussion/django_comment_client/settings.py index d28d60efa6..68613436d6 100644 --- a/lms/djangoapps/discussion/django_comment_client/settings.py +++ b/lms/djangoapps/discussion/django_comment_client/settings.py @@ -1,4 +1,4 @@ -# pylint: disable=missing-docstring +# pylint: disable=missing-module-docstring from django.conf import settings diff --git a/lms/djangoapps/discussion/django_comment_client/tests/factories.py b/lms/djangoapps/discussion/django_comment_client/tests/factories.py index 43090c099f..f77c3236e6 100644 --- a/lms/djangoapps/discussion/django_comment_client/tests/factories.py +++ b/lms/djangoapps/discussion/django_comment_client/tests/factories.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - from factory.django import DjangoModelFactory from openedx.core.djangoapps.django_comment_common.models import Permission, Role diff --git a/lms/djangoapps/discussion/django_comment_client/tests/mock_cs_server/test_mock_cs_server.py b/lms/djangoapps/discussion/django_comment_client/tests/mock_cs_server/test_mock_cs_server.py index 15277906e3..c9db7b5988 100644 --- a/lms/djangoapps/discussion/django_comment_client/tests/mock_cs_server/test_mock_cs_server.py +++ b/lms/djangoapps/discussion/django_comment_client/tests/mock_cs_server/test_mock_cs_server.py @@ -1,12 +1,8 @@ -# pylint: disable=missing-docstring - - import json import threading import unittest import pytest -import six.moves.urllib.request # pylint: disable=import-error from lms.djangoapps.discussion.django_comment_client.tests.mock_cs_server.mock_cs_server import MockCommentServiceServer diff --git a/lms/djangoapps/discussion/django_comment_client/tests/test_middleware.py b/lms/djangoapps/discussion/django_comment_client/tests/test_middleware.py index 778b71e767..3f77e1ce0c 100644 --- a/lms/djangoapps/discussion/django_comment_client/tests/test_middleware.py +++ b/lms/djangoapps/discussion/django_comment_client/tests/test_middleware.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - import json import django.http diff --git a/lms/djangoapps/discussion/django_comment_client/tests/unicode.py b/lms/djangoapps/discussion/django_comment_client/tests/unicode.py index a750b6ba0b..017a0371ec 100644 --- a/lms/djangoapps/discussion/django_comment_client/tests/unicode.py +++ b/lms/djangoapps/discussion/django_comment_client/tests/unicode.py @@ -1,4 +1,3 @@ -# pylint: disable=missing-docstring # coding=utf-8 diff --git a/lms/djangoapps/discussion/management/commands/assign_role.py b/lms/djangoapps/discussion/management/commands/assign_role.py index f306f1da90..00f6273c84 100644 --- a/lms/djangoapps/discussion/management/commands/assign_role.py +++ b/lms/djangoapps/discussion/management/commands/assign_role.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - from django.contrib.auth.models import User from django.core.management.base import BaseCommand diff --git a/lms/djangoapps/discussion/management/commands/assign_roles_for_course.py b/lms/djangoapps/discussion/management/commands/assign_roles_for_course.py index 5c589431f0..e721279053 100644 --- a/lms/djangoapps/discussion/management/commands/assign_roles_for_course.py +++ b/lms/djangoapps/discussion/management/commands/assign_roles_for_course.py @@ -1,4 +1,3 @@ -# pylint: disable=missing-docstring """ This must be run only after seed_permissions_roles.py! diff --git a/lms/djangoapps/discussion/management/commands/get_discussion_link.py b/lms/djangoapps/discussion/management/commands/get_discussion_link.py index b5b756bfb6..d669b67771 100644 --- a/lms/djangoapps/discussion/management/commands/get_discussion_link.py +++ b/lms/djangoapps/discussion/management/commands/get_discussion_link.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - from django.core.management.base import BaseCommand, CommandError from opaque_keys.edx.keys import CourseKey diff --git a/lms/djangoapps/discussion/management/commands/reload_forum_users.py b/lms/djangoapps/discussion/management/commands/reload_forum_users.py index 7b25b9ec8c..4013605829 100644 --- a/lms/djangoapps/discussion/management/commands/reload_forum_users.py +++ b/lms/djangoapps/discussion/management/commands/reload_forum_users.py @@ -1,4 +1,3 @@ -# pylint: disable=missing-docstring,broad-except """ Reload forum (comment client) users from existing users. """ diff --git a/lms/djangoapps/discussion/management/commands/seed_permissions_roles.py b/lms/djangoapps/discussion/management/commands/seed_permissions_roles.py index 6dc624093f..54e194e062 100644 --- a/lms/djangoapps/discussion/management/commands/seed_permissions_roles.py +++ b/lms/djangoapps/discussion/management/commands/seed_permissions_roles.py @@ -1,4 +1,3 @@ -# pylint: disable=missing-docstring """ Management command to seed default permissions and roles. """ diff --git a/lms/djangoapps/discussion/management/commands/show_permissions.py b/lms/djangoapps/discussion/management/commands/show_permissions.py index 88930cf9bd..bd091c8168 100644 --- a/lms/djangoapps/discussion/management/commands/show_permissions.py +++ b/lms/djangoapps/discussion/management/commands/show_permissions.py @@ -1,4 +1,4 @@ -# pylint: disable=missing-docstring,too-many-format-args +# pylint: disable=missing-module-docstring,too-many-format-args from django.contrib.auth.models import User diff --git a/lms/djangoapps/discussion/notification_prefs/__init__.py b/lms/djangoapps/discussion/notification_prefs/__init__.py index ea3cc69021..daed38e2b0 100644 --- a/lms/djangoapps/discussion/notification_prefs/__init__.py +++ b/lms/djangoapps/discussion/notification_prefs/__init__.py @@ -1,2 +1 @@ -# pylint: disable=missing-docstring NOTIFICATION_PREF_KEY = "notification_pref" diff --git a/lms/djangoapps/discussion/notification_prefs/tests.py b/lms/djangoapps/discussion/notification_prefs/tests.py index 6efe5e3f90..d86d8871c6 100644 --- a/lms/djangoapps/discussion/notification_prefs/tests.py +++ b/lms/djangoapps/discussion/notification_prefs/tests.py @@ -1,4 +1,4 @@ -# pylint: disable=missing-docstring,consider-iterating-dictionary +# pylint: disable=consider-iterating-dictionary, missing-module-docstring import json diff --git a/lms/djangoapps/discussion/notification_prefs/views.py b/lms/djangoapps/discussion/notification_prefs/views.py index a91996e623..20e631bbf6 100644 --- a/lms/djangoapps/discussion/notification_prefs/views.py +++ b/lms/djangoapps/discussion/notification_prefs/views.py @@ -1,4 +1,3 @@ -# pylint: disable=missing-docstring """ Views to support notification preferences. """ @@ -96,7 +95,7 @@ class UsernameCipher(object): try: unpadded = unpadder.update(decrypted) + unpadder.finalize() - if len(unpadded) == 0: # pylint: disable=len-as-condition + if len(unpadded) == 0: raise UsernameDecryptionException("padding") return unpadded except ValueError: @@ -173,7 +172,7 @@ def ajax_status(request): @require_GET -def set_subscription(request, token, subscribe): # pylint: disable=unused-argument +def set_subscription(request, token, subscribe): """ A view that disables or re-enables notifications for a user who may not be authenticated diff --git a/lms/djangoapps/discussion/notifier_api/serializers.py b/lms/djangoapps/discussion/notifier_api/serializers.py index 3bcb68b8fa..4d1dbbb5be 100644 --- a/lms/djangoapps/discussion/notifier_api/serializers.py +++ b/lms/djangoapps/discussion/notifier_api/serializers.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - import six from django.contrib.auth.models import User from django.http import Http404 diff --git a/lms/djangoapps/discussion/rest_api/api.py b/lms/djangoapps/discussion/rest_api/api.py index 20c251c51a..5bbea6df41 100644 --- a/lms/djangoapps/discussion/rest_api/api.py +++ b/lms/djangoapps/discussion/rest_api/api.py @@ -14,7 +14,7 @@ from django.urls import reverse from opaque_keys import InvalidKeyError from opaque_keys.edx.locator import CourseKey from rest_framework.exceptions import PermissionDenied -from six.moves.urllib.parse import urlencode, urlunparse # pylint: disable=import-error +from six.moves.urllib.parse import urlencode, urlunparse from lms.djangoapps.courseware.courses import get_course_with_access from lms.djangoapps.courseware.exceptions import CourseAccessRedirect diff --git a/lms/djangoapps/discussion/rest_api/forms.py b/lms/djangoapps/discussion/rest_api/forms.py index 85a879a7b9..266ac12918 100644 --- a/lms/djangoapps/discussion/rest_api/forms.py +++ b/lms/djangoapps/discussion/rest_api/forms.py @@ -3,9 +3,9 @@ Discussion API forms """ -import six.moves.urllib.error # pylint: disable=import-error -import six.moves.urllib.parse # pylint: disable=import-error -import six.moves.urllib.request # pylint: disable=import-error +import six.moves.urllib.error +import six.moves.urllib.parse +import six.moves.urllib.request from django.core.exceptions import ValidationError from django.forms import BooleanField, CharField, ChoiceField, Form, IntegerField from opaque_keys import InvalidKeyError @@ -173,7 +173,6 @@ class CourseDiscussionRolesForm(CourseDiscussionSettingsForm): def clean_rolename(self): """Validate the 'rolename' value.""" - # pylint: disable=too-many-function-args rolename = six.moves.urllib.parse.unquote(self.cleaned_data.get('rolename')) course_id = self.cleaned_data.get('course_key') if course_id and rolename: diff --git a/lms/djangoapps/discussion/rest_api/serializers.py b/lms/djangoapps/discussion/rest_api/serializers.py index ecc840f153..414c9bdc37 100644 --- a/lms/djangoapps/discussion/rest_api/serializers.py +++ b/lms/djangoapps/discussion/rest_api/serializers.py @@ -7,7 +7,7 @@ from django.contrib.auth.models import User as DjangoUser from django.core.exceptions import ValidationError from django.urls import reverse from rest_framework import serializers -from six.moves.urllib.parse import urlencode, urlunparse # pylint: disable=import-error +from six.moves.urllib.parse import urlencode, urlunparse from lms.djangoapps.discussion.django_comment_client.utils import ( course_discussion_division_enabled, diff --git a/lms/djangoapps/discussion/rest_api/tests/test_api.py b/lms/djangoapps/discussion/rest_api/tests/test_api.py index 530228ce1c..c993890b72 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_api.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_api.py @@ -16,7 +16,7 @@ from opaque_keys.edx.locator import CourseLocator from pytz import UTC from rest_framework.exceptions import PermissionDenied from six.moves import range -from six.moves.urllib.parse import parse_qs, urlencode, urlparse, urlunparse # pylint: disable=import-error +from six.moves.urllib.parse import parse_qs, urlencode, urlparse, urlunparse from common.test.utils import MockSignalHandlerMixin, disable_signal from lms.djangoapps.courseware.tests.factories import BetaTesterFactory, StaffFactory diff --git a/lms/djangoapps/discussion/rest_api/tests/test_forms.py b/lms/djangoapps/discussion/rest_api/tests/test_forms.py index 8afb23ee86..9df8aee20a 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_forms.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_forms.py @@ -9,7 +9,7 @@ from unittest import TestCase import ddt from django.http import QueryDict from opaque_keys.edx.locator import CourseLocator -from six.moves.urllib.parse import urlencode # pylint: disable=import-error +from six.moves.urllib.parse import urlencode from lms.djangoapps.discussion.rest_api.forms import CommentListGetForm, ThreadListGetForm from openedx.core.djangoapps.util.test_forms import FormTestMixin diff --git a/lms/djangoapps/discussion/rest_api/tests/test_serializers.py b/lms/djangoapps/discussion/rest_api/tests/test_serializers.py index 8e88d100fb..a4b8d1a601 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_serializers.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_serializers.py @@ -10,7 +10,7 @@ import httpretty import mock import six from django.test.client import RequestFactory -from six.moves.urllib.parse import urlparse # pylint: disable=import-error +from six.moves.urllib.parse import urlparse from lms.djangoapps.discussion.django_comment_client.tests.utils import ForumsEnableMixin from lms.djangoapps.discussion.rest_api.serializers import CommentSerializer, ThreadSerializer, get_context diff --git a/lms/djangoapps/discussion/rest_api/tests/test_views.py b/lms/djangoapps/discussion/rest_api/tests/test_views.py index f625091650..8029dd1173 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_views.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_views.py @@ -16,7 +16,7 @@ from rest_framework.parsers import JSONParser from rest_framework.test import APIClient, APITestCase from six import text_type from six.moves import range -from six.moves.urllib.parse import urlparse # pylint: disable=import-error +from six.moves.urllib.parse import urlparse from common.test.utils import disable_signal from course_modes.models import CourseMode diff --git a/lms/djangoapps/discussion/rest_api/tests/utils.py b/lms/djangoapps/discussion/rest_api/tests/utils.py index 172e04e839..0620ffe032 100644 --- a/lms/djangoapps/discussion/rest_api/tests/utils.py +++ b/lms/djangoapps/discussion/rest_api/tests/utils.py @@ -522,7 +522,7 @@ class ProfileImageTestMixin(object): self.assertTrue(storage.exists(name)) with closing(Image.open(storage.path(name))) as img: self.assertEqual(img.size, (size, size)) - self.assertEqual(img.format, 'JPEG') # pylint: disable=no-member + self.assertEqual(img.format, 'JPEG') else: self.assertFalse(storage.exists(name)) diff --git a/lms/djangoapps/discussion/tasks.py b/lms/djangoapps/discussion/tasks.py index 3420288367..a0101e85b4 100644 --- a/lms/djangoapps/discussion/tasks.py +++ b/lms/djangoapps/discussion/tasks.py @@ -17,7 +17,7 @@ from edx_ace.recipient import Recipient from edx_ace.utils import date from eventtracking import tracker from opaque_keys.edx.keys import CourseKey -from six.moves.urllib.parse import urljoin # pylint: disable=import-error +from six.moves.urllib.parse import urljoin import openedx.core.djangoapps.django_comment_common.comment_client as cc from lms.djangoapps.discussion.django_comment_client.utils import ( diff --git a/lms/djangoapps/discussion/tests/test_tasks.py b/lms/djangoapps/discussion/tests/test_tasks.py index 4161792a98..5f828b102a 100644 --- a/lms/djangoapps/discussion/tests/test_tasks.py +++ b/lms/djangoapps/discussion/tests/test_tasks.py @@ -232,7 +232,6 @@ class TaskTestCase(ModuleStoreTestCase): with emulate_http_request( site=message.context['site'], user=self.thread_author ): - # pylint: disable=unsupported-membership-test rendered_email = EmailRenderer().render(get_channel_for_message(ChannelType.EMAIL, message), message) assert self.comment['body'] in rendered_email.body_html assert self.comment_author.username in rendered_email.body_html diff --git a/lms/djangoapps/discussion/tests/test_views.py b/lms/djangoapps/discussion/tests/test_views.py index 0fe34381fe..5c3274b01a 100644 --- a/lms/djangoapps/discussion/tests/test_views.py +++ b/lms/djangoapps/discussion/tests/test_views.py @@ -72,8 +72,6 @@ log = logging.getLogger(__name__) QUERY_COUNT_TABLE_BLACKLIST = WAFFLE_TABLES -# pylint: disable=missing-docstring - class ViewsExceptionTestCase(UrlResetMixin, ModuleStoreTestCase): @@ -769,8 +767,10 @@ class ForumFormDiscussionContentGroupTestCase(ForumsEnableMixin, ContentGroupTes self.thread_list = [ {"thread_id": "test_general_thread_id"}, {"thread_id": "test_global_group_thread_id", "commentable_id": self.global_module.discussion_id}, - {"thread_id": "test_alpha_group_thread_id", "group_id": self.alpha_module.group_access[0][0], "commentable_id": self.alpha_module.discussion_id}, # pylint: disable=line-too-long - {"thread_id": "test_beta_group_thread_id", "group_id": self.beta_module.group_access[0][0], "commentable_id": self.beta_module.discussion_id} # pylint: disable=line-too-long + {"thread_id": "test_alpha_group_thread_id", "group_id": self.alpha_module.group_access[0][0], + "commentable_id": self.alpha_module.discussion_id}, + {"thread_id": "test_beta_group_thread_id", "group_id": self.beta_module.group_access[0][0], + "commentable_id": self.beta_module.discussion_id} ] def assert_has_access(self, response, expected_discussion_threads): @@ -1633,7 +1633,7 @@ class ForumDiscussionXSSTestCase(ForumsEnableMixin, UrlResetMixin, ModuleStoreTe @ddt.data('">', '', '') @patch('student.models.cc.User.from_django_user') - def test_forum_discussion_xss_prevent(self, malicious_code, mock_user, mock_req): # pylint: disable=unused-argument + def test_forum_discussion_xss_prevent(self, malicious_code, mock_user, mock_req): """ Test that XSS attack is prevented """ diff --git a/lms/djangoapps/edxnotes/helpers.py b/lms/djangoapps/edxnotes/helpers.py index 9a79a7a923..437018a6f4 100644 --- a/lms/djangoapps/edxnotes/helpers.py +++ b/lms/djangoapps/edxnotes/helpers.py @@ -11,7 +11,7 @@ from uuid import uuid4 import requests import six -from six.moves.urllib.parse import urlencode, urlparse, parse_qs # pylint: disable=import-error +from six.moves.urllib.parse import urlencode, urlparse, parse_qs from dateutil.parser import parse as dateutil_parse from django.conf import settings from django.core.exceptions import ImproperlyConfigured @@ -449,7 +449,7 @@ def generate_uid(): """ Generates unique id. """ - return uuid4().int # pylint: disable=no-member + return uuid4().int def is_feature_enabled(course, user): diff --git a/lms/djangoapps/edxnotes/tests.py b/lms/djangoapps/edxnotes/tests.py index 8fce8bc8d7..ae3fb317ed 100644 --- a/lms/djangoapps/edxnotes/tests.py +++ b/lms/djangoapps/edxnotes/tests.py @@ -12,7 +12,7 @@ import ddt import jwt import six from six import text_type -from six.moves.urllib.parse import urlparse, parse_qs # pylint: disable=import-error +from six.moves.urllib.parse import urlparse, parse_qs from django.conf import settings from django.contrib.auth.models import AnonymousUser from django.core.exceptions import ImproperlyConfigured diff --git a/lms/djangoapps/edxnotes/views.py b/lms/djangoapps/edxnotes/views.py index 600a11d8fa..7551673392 100644 --- a/lms/djangoapps/edxnotes/views.py +++ b/lms/djangoapps/edxnotes/views.py @@ -180,7 +180,6 @@ def notes(request, course_id): return HttpResponse(json.dumps(notes_info, cls=NoteJSONEncoder), content_type="application/json") -# pylint: disable=unused-argument @login_required def get_token(request, course_id): """ diff --git a/lms/djangoapps/experiments/tests/test_views.py b/lms/djangoapps/experiments/tests/test_views.py index 616cf58201..e1615701e1 100644 --- a/lms/djangoapps/experiments/tests/test_views.py +++ b/lms/djangoapps/experiments/tests/test_views.py @@ -5,9 +5,9 @@ Tests for experimentation views import unittest -import six.moves.urllib.error # pylint: disable=import-error -import six.moves.urllib.parse # pylint: disable=import-error -import six.moves.urllib.request # pylint: disable=import-error +import six.moves.urllib.error +import six.moves.urllib.parse +import six.moves.urllib.request from django.conf import settings from django.core.handlers.wsgi import WSGIRequest from django.test.utils import override_settings diff --git a/lms/djangoapps/gating/apps.py b/lms/djangoapps/gating/apps.py index efb4b92a32..26281c8638 100644 --- a/lms/djangoapps/gating/apps.py +++ b/lms/djangoapps/gating/apps.py @@ -14,4 +14,4 @@ class GatingConfig(AppConfig): def ready(self): # Import signals to wire up the signal handlers contained within - from gating import signals # pylint: disable=unused-variable + from gating import signals # pylint: disable=unused-import diff --git a/lms/djangoapps/grades/apps.py b/lms/djangoapps/grades/apps.py index bd2caff9ac..7abbaff757 100644 --- a/lms/djangoapps/grades/apps.py +++ b/lms/djangoapps/grades/apps.py @@ -41,7 +41,7 @@ class GradesConfig(AppConfig): """ # Can't import models at module level in AppConfigs, and models get # included from the signal handlers - from .signals import handlers # pylint: disable=unused-variable + from .signals import handlers # pylint: disable=unused-import if settings.FEATURES.get('ENABLE_SPECIAL_EXAMS'): from .services import GradesService set_runtime_service('grades', GradesService()) diff --git a/lms/djangoapps/grades/rest_api/v1/tests/test_views.py b/lms/djangoapps/grades/rest_api/v1/tests/test_views.py index 287697e8ee..9c89bf4d94 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/test_views.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/test_views.py @@ -100,7 +100,7 @@ class SingleUserGradesTests(GradeViewTestMixin, AuthAndScopesTestMixin, APITestC """ Test that a request for an invalid course key returns an error. """ - def mock_from_string(*args, **kwargs): # pylint: disable=unused-argument + def mock_from_string(*args, **kwargs): """Mocked function to always raise an exception""" raise InvalidKeyError('foo', 'bar') diff --git a/lms/djangoapps/grades/tests/integration/test_problems.py b/lms/djangoapps/grades/tests/integration/test_problems.py index c2e589866d..ae1815b092 100644 --- a/lms/djangoapps/grades/tests/integration/test_problems.py +++ b/lms/djangoapps/grades/tests/integration/test_problems.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - import datetime import itertools diff --git a/lms/djangoapps/grades/tests/test_course_grade.py b/lms/djangoapps/grades/tests/test_course_grade.py index 7520cc03f3..6920621fdc 100644 --- a/lms/djangoapps/grades/tests/test_course_grade.py +++ b/lms/djangoapps/grades/tests/test_course_grade.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - import ddt import six from crum import set_current_request diff --git a/lms/djangoapps/grades/tests/test_course_grade_factory.py b/lms/djangoapps/grades/tests/test_course_grade_factory.py index dc41c26978..fe1b193870 100644 --- a/lms/djangoapps/grades/tests/test_course_grade_factory.py +++ b/lms/djangoapps/grades/tests/test_course_grade_factory.py @@ -202,12 +202,12 @@ class TestCourseGradeFactory(GradeTestBase): 'Homework': { 'category': 'Homework', 'percent': 0.25, - 'detail': 'Homework = 25.00% of a possible 100.00%', # pylint: disable=unicode-format-string + 'detail': 'Homework = 25.00% of a possible 100.00%', }, 'NoCredit': { 'category': 'NoCredit', 'percent': 0.0, - 'detail': 'NoCredit = 0.00% of a possible 0.00%', # pylint: disable=unicode-format-string + 'detail': 'NoCredit = 0.00% of a possible 0.00%', } }, 'percent': 0.25, diff --git a/lms/djangoapps/instructor/message_types.py b/lms/djangoapps/instructor/message_types.py index 51429e29aa..ca96316eaa 100644 --- a/lms/djangoapps/instructor/message_types.py +++ b/lms/djangoapps/instructor/message_types.py @@ -16,7 +16,7 @@ class AccountCreationAndEnrollment(BaseMessageType): def __init__(self, *args, **kwargs): super(AccountCreationAndEnrollment, self).__init__(*args, **kwargs) - self.options['transactional'] = True # pylint: disable=unsupported-assignment-operation + self.options['transactional'] = True class AddBetaTester(BaseMessageType): @@ -27,7 +27,7 @@ class AddBetaTester(BaseMessageType): def __init__(self, *args, **kwargs): super(AddBetaTester, self).__init__(*args, **kwargs) - self.options['transactional'] = True # pylint: disable=unsupported-assignment-operation + self.options['transactional'] = True class AllowedEnroll(BaseMessageType): @@ -38,7 +38,7 @@ class AllowedEnroll(BaseMessageType): def __init__(self, *args, **kwargs): super(AllowedEnroll, self).__init__(*args, **kwargs) - self.options['transactional'] = True # pylint: disable=unsupported-assignment-operation + self.options['transactional'] = True class AllowedUnenroll(BaseMessageType): @@ -49,7 +49,7 @@ class AllowedUnenroll(BaseMessageType): def __init__(self, *args, **kwargs): super(AllowedUnenroll, self).__init__(*args, **kwargs) - self.options['transactional'] = True # pylint: disable=unsupported-assignment-operation + self.options['transactional'] = True class EnrollEnrolled(BaseMessageType): @@ -60,7 +60,7 @@ class EnrollEnrolled(BaseMessageType): def __init__(self, *args, **kwargs): super(EnrollEnrolled, self).__init__(*args, **kwargs) - self.options['transactional'] = True # pylint: disable=unsupported-assignment-operation + self.options['transactional'] = True class EnrolledUnenroll(BaseMessageType): @@ -71,7 +71,7 @@ class EnrolledUnenroll(BaseMessageType): def __init__(self, *args, **kwargs): super(EnrolledUnenroll, self).__init__(*args, **kwargs) - self.options['transactional'] = True # pylint: disable=unsupported-assignment-operation + self.options['transactional'] = True class RemoveBetaTester(BaseMessageType): @@ -82,4 +82,4 @@ class RemoveBetaTester(BaseMessageType): def __init__(self, *args, **kwargs): super(RemoveBetaTester, self).__init__(*args, **kwargs) - self.options['transactional'] = True # pylint: disable=unsupported-assignment-operation + self.options['transactional'] = True diff --git a/lms/djangoapps/instructor/tests/test_api.py b/lms/djangoapps/instructor/tests/test_api.py index e75fc2b496..b2c57f4054 100644 --- a/lms/djangoapps/instructor/tests/test_api.py +++ b/lms/djangoapps/instructor/tests/test_api.py @@ -30,7 +30,7 @@ from mock import Mock, NonCallableMock, patch from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.locator import UsageKey from pytz import UTC -from six import text_type, unichr # pylint: disable=redefined-builtin +from six import text_type, unichr from six.moves import range, zip from testfixtures import LogCapture @@ -249,25 +249,25 @@ def reverse(endpoint, args=None, kwargs=None, is_dashboard_endpoint=True): @common_exceptions_400 -def view_success(request): # pylint: disable=unused-argument +def view_success(request): "A dummy view for testing that returns a simple HTTP response" return HttpResponse('success') @common_exceptions_400 -def view_user_doesnotexist(request): # pylint: disable=unused-argument +def view_user_doesnotexist(request): "A dummy view that raises a User.DoesNotExist exception" raise User.DoesNotExist() @common_exceptions_400 -def view_alreadyrunningerror(request): # pylint: disable=unused-argument +def view_alreadyrunningerror(request): "A dummy view that raises an AlreadyRunningError exception" raise AlreadyRunningError() @common_exceptions_400 -def view_alreadyrunningerror_unicode(request): # pylint: disable=unused-argument +def view_alreadyrunningerror_unicode(request): """ A dummy view that raises an AlreadyRunningError exception with unicode message """ @@ -275,7 +275,7 @@ def view_alreadyrunningerror_unicode(request): # pylint: disable=unused-argumen @common_exceptions_400 -def view_queue_connection_error(request): # pylint: disable=unused-argument +def view_queue_connection_error(request): """ A dummy view that raises a QueueConnectionError exception. """ @@ -299,24 +299,24 @@ class TestCommonExceptions400(TestCase): def test_user_doesnotexist(self): self.request.is_ajax.return_value = False - resp = view_user_doesnotexist(self.request) # pylint: disable=assignment-from-no-return + resp = view_user_doesnotexist(self.request) self.assertContains(resp, "User does not exist", status_code=400) def test_user_doesnotexist_ajax(self): self.request.is_ajax.return_value = True - resp = view_user_doesnotexist(self.request) # pylint: disable=assignment-from-no-return + resp = view_user_doesnotexist(self.request) self.assertContains(resp, "User does not exist", status_code=400) @ddt.data(True, False) def test_alreadyrunningerror(self, is_ajax): self.request.is_ajax.return_value = is_ajax - resp = view_alreadyrunningerror(self.request) # pylint: disable=assignment-from-no-return + resp = view_alreadyrunningerror(self.request) self.assertContains(resp, "Requested task is already running", status_code=400) @ddt.data(True, False) def test_alreadyrunningerror_with_unicode(self, is_ajax): self.request.is_ajax.return_value = is_ajax - resp = view_alreadyrunningerror_unicode(self.request) # pylint: disable=assignment-from-no-return + resp = view_alreadyrunningerror_unicode(self.request) self.assertContains( resp, u'Text with unicode chárácters', @@ -329,7 +329,7 @@ class TestCommonExceptions400(TestCase): Tests that QueueConnectionError exception is handled in common_exception_400. """ self.request.is_ajax.return_value = is_ajax - resp = view_queue_connection_error(self.request) # pylint: disable=assignment-from-no-return + resp = view_queue_connection_error(self.request) self.assertContains( resp, 'Error occured. Please try again later', diff --git a/lms/djangoapps/instructor/tests/test_tools.py b/lms/djangoapps/instructor/tests/test_tools.py index bad04525a0..13294fc97d 100644 --- a/lms/djangoapps/instructor/tests/test_tools.py +++ b/lms/djangoapps/instructor/tests/test_tools.py @@ -43,7 +43,6 @@ class TestHandleDashboardError(unittest.TestCase): Test handle_dashboard_error decorator. """ def test_error(self): - # pylint: disable=unused-argument @tools.handle_dashboard_error def view(request, course_id): """ @@ -55,7 +54,6 @@ class TestHandleDashboardError(unittest.TestCase): self.assertEqual(response, {'error': 'Oh noes!'}) def test_no_error(self): - # pylint: disable=unused-argument @tools.handle_dashboard_error def view(request, course_id): """ diff --git a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py index 856d5ac5fb..54263a679c 100644 --- a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py +++ b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py @@ -197,7 +197,8 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase, XssT } ) response = self.client.get(url) - reason_field = '' # pylint: disable=line-too-long + reason_field = '' if enbale_reason_field: self.assertContains(response, reason_field) else: @@ -424,7 +425,8 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase, XssT Test analytics dashboard message is shown """ response = self.client.get(self.url) - analytics_section = '' # pylint: disable=line-too-long + analytics_section = '' self.assertContains(response, analytics_section) # link to dashboard shown diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index b85c901c7f..b3c7f6877f 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -164,7 +164,7 @@ def common_exceptions_400(func): (decorator without arguments) """ - def wrapped(request, *args, **kwargs): # pylint: disable=missing-docstring + def wrapped(request, *args, **kwargs): use_json = (request.is_ajax() or request.META.get("HTTP_ACCEPT", "").startswith("application/json")) try: @@ -198,8 +198,8 @@ def require_post_params(*args, **kwargs): required_params += [(key, kwargs[key]) for key in kwargs] # required_params = e.g. [('action', 'enroll or unenroll'), ['emails', None]] - def decorator(func): # pylint: disable=missing-docstring - def wrapped(*args, **kwargs): # pylint: disable=missing-docstring + def decorator(func): + def wrapped(*args, **kwargs): request = args[0] error_response_data = { @@ -231,7 +231,7 @@ def require_course_permission(permission): Assumes that request is in args[0]. Assumes that course_id is in kwargs['course_id']. """ - def decorator(func): # pylint: disable=missing-docstring + def decorator(func): def wrapped(*args, **kwargs): request = args[0] course = get_course_by_id(CourseKey.from_string(kwargs['course_id'])) @@ -252,7 +252,7 @@ def require_sales_admin(func): If the user does not have privileges for this operation, this will return HttpResponseForbidden (403). """ - def wrapped(request, course_id): # pylint: disable=missing-docstring + def wrapped(request, course_id): try: course_key = CourseKey.from_string(course_id) @@ -277,7 +277,7 @@ def require_finance_admin(func): If the user does not have privileges for this operation, this will return HttpResponseForbidden (403). """ - def wrapped(request, course_id): # pylint: disable=missing-docstring + def wrapped(request, course_id): try: course_key = CourseKey.from_string(course_id) @@ -1069,7 +1069,7 @@ def get_grading_config(request, course_id): @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_course_permission(permissions.CAN_RESEARCH) -def get_sale_records(request, course_id, csv=False): # pylint: disable=unused-argument, redefined-outer-name +def get_sale_records(request, course_id, csv=False): # pylint: disable=redefined-outer-name """ return the summary of all sales records for a particular course """ @@ -1100,7 +1100,7 @@ def get_sale_records(request, course_id, csv=False): # pylint: disable=unused-a @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_course_permission(permissions.CAN_RESEARCH) -def get_sale_order_records(request, course_id): # pylint: disable=unused-argument +def get_sale_order_records(request, course_id): """ return the summary of all sales records for a particular course """ @@ -1462,7 +1462,7 @@ class CohortCSV(DeveloperErrorViewMixin, APIView): @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_course_permission(permissions.VIEW_COUPONS) -def get_coupon_codes(request, course_id): # pylint: disable=unused-argument +def get_coupon_codes(request, course_id): """ Respond with csv which contains a summary of all Active Coupons. """ @@ -1472,7 +1472,7 @@ def get_coupon_codes(request, course_id): # pylint: disable=unused-argument query_features = [ ('code', _('Coupon Code')), ('course_id', _('Course Id')), - ('percentage_discount', _('% Discount')), # pylint: disable=unicode-format-string + ('percentage_discount', _('% Discount')), ('description', _('Description')), ('expiration_date', _('Expiration Date')), ('is_active', _('Is Active')), @@ -1895,7 +1895,7 @@ def spent_registration_codes(request, course_id): @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_course_permission(permissions.CAN_RESEARCH) -def get_anon_ids(request, course_id): # pylint: disable=unused-argument +def get_anon_ids(request, course_id): """ Respond with 2-column CSV output of user-id, anonymized-user-id """ @@ -2373,7 +2373,7 @@ def rescore_entrance_exam(request, course_id): @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_course_permission(permissions.EMAIL) -def list_background_email_tasks(request, course_id): # pylint: disable=unused-argument +def list_background_email_tasks(request, course_id): """ List background email tasks. """ @@ -2395,7 +2395,7 @@ def list_background_email_tasks(request, course_id): # pylint: disable=unused-a @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_course_permission(permissions.EMAIL) -def list_email_content(request, course_id): # pylint: disable=unused-argument +def list_email_content(request, course_id): """ List the content of bulk emails sent """ @@ -2816,7 +2816,7 @@ def update_forum_role_membership(request, course_id): @require_POST -def get_user_invoice_preference(request, course_id): # pylint: disable=unused-argument +def get_user_invoice_preference(request, course_id): """ Gets invoice copy user's preferences. """ @@ -2965,7 +2965,7 @@ def _instructor_dash_url(course_key, section=None): @require_global_staff @require_POST -def generate_example_certificates(request, course_id=None): # pylint: disable=unused-argument +def generate_example_certificates(request, course_id=None): """Start generating a set of example certificates. Example certificates are used to verify that certificates have @@ -3186,7 +3186,7 @@ def remove_certificate_exception(course_key, student): ) try: - generated_certificate = GeneratedCertificate.objects.get( # pylint: disable=no-member + generated_certificate = GeneratedCertificate.objects.get( user=student, course_id=course_key ) diff --git a/lms/djangoapps/instructor/views/coupons.py b/lms/djangoapps/instructor/views/coupons.py index 2b0e5723b5..7142a06e02 100644 --- a/lms/djangoapps/instructor/views/coupons.py +++ b/lms/djangoapps/instructor/views/coupons.py @@ -22,7 +22,7 @@ log = logging.getLogger(__name__) @require_POST @login_required -def remove_coupon(request, course_id): # pylint: disable=unused-argument +def remove_coupon(request, course_id): """ remove the coupon against the coupon id set the coupon is_active flag to false @@ -113,7 +113,7 @@ def add_coupon(request, course_id): @require_POST @login_required -def update_coupon(request, course_id): # pylint: disable=unused-argument +def update_coupon(request, course_id): """ update the coupon object in the database """ @@ -138,7 +138,7 @@ def update_coupon(request, course_id): # pylint: disable=unused-argument @require_POST @login_required -def get_coupon_info(request, course_id): # pylint: disable=unused-argument +def get_coupon_info(request, course_id): """ get the coupon information to display in the pop up form """ diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index f9dbe22828..02be7bccf1 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -6,7 +6,7 @@ Instructor Dashboard Views import datetime import logging import uuid -from functools import reduce # pylint: disable=redefined-builtin +from functools import reduce import pytz import six @@ -25,7 +25,7 @@ from mock import patch from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey from six import text_type -from six.moves.urllib.parse import urljoin # pylint: disable=import-error +from six.moves.urllib.parse import urljoin from xblock.field_data import DictFieldData from xblock.fields import ScopeIds @@ -508,7 +508,8 @@ def _section_course_info(course, access): try: sorted_cutoffs = sorted(list(course.grade_cutoffs.items()), key=lambda i: i[1], reverse=True) - advance = lambda memo, letter_score_tuple: u"{}: {}, ".format(letter_score_tuple[0], letter_score_tuple[1]) + memo # pylint: disable=line-too-long + advance = lambda memo, letter_score_tuple: u"{}: {}, ".format(letter_score_tuple[0], letter_score_tuple[1]) \ + + memo section_data['grade_cutoffs'] = reduce(advance, sorted_cutoffs, "")[:-2] except Exception: # pylint: disable=broad-except section_data['grade_cutoffs'] = "Not Available" diff --git a/lms/djangoapps/instructor_task/tasks_helper/certs.py b/lms/djangoapps/instructor_task/tasks_helper/certs.py index 714a32b2d7..047beacf6a 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/certs.py +++ b/lms/djangoapps/instructor_task/tasks_helper/certs.py @@ -134,7 +134,7 @@ def invalidate_generated_certificates(course_id, enrolled_students, certificate_ :param enrolled_students: (queryset or list) students enrolled in the course :param certificate_statuses: certificates statuses for whom to remove generated certificate """ - certificates = GeneratedCertificate.objects.filter( # pylint: disable=no-member + certificates = GeneratedCertificate.objects.filter( user__in=enrolled_students, course_id=course_id, status__in=certificate_statuses, diff --git a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py index 3622ed0956..7c131e6f90 100644 --- a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py +++ b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py @@ -26,7 +26,7 @@ from mock import ANY, MagicMock, Mock, patch from pytz import UTC from six import text_type from six.moves import range, zip -from six.moves.urllib.parse import quote # pylint: disable=import-error +from six.moves.urllib.parse import quote from waffle.testutils import override_switch import openedx.core.djangoapps.user_api.course_tag.api as course_tag_api diff --git a/lms/djangoapps/learner_dashboard/tests/test_programs.py b/lms/djangoapps/learner_dashboard/tests/test_programs.py index 18463a33fd..2d27052c01 100644 --- a/lms/djangoapps/learner_dashboard/tests/test_programs.py +++ b/lms/djangoapps/learner_dashboard/tests/test_programs.py @@ -10,7 +10,7 @@ from uuid import uuid4 import mock import six -from six.moves.urllib.parse import urljoin # pylint: disable=import-error +from six.moves.urllib.parse import urljoin from bs4 import BeautifulSoup from django.conf import settings from django.test import override_settings diff --git a/lms/djangoapps/lms_xblock/field_data.py b/lms/djangoapps/lms_xblock/field_data.py index dff09c79d3..6866c32187 100644 --- a/lms/djangoapps/lms_xblock/field_data.py +++ b/lms/djangoapps/lms_xblock/field_data.py @@ -17,7 +17,7 @@ class LmsFieldData(SplitFieldData): def __init__(self, authored_data, student_data): # Make sure that we don't repeatedly nest LmsFieldData instances if isinstance(authored_data, LmsFieldData): - authored_data = authored_data._authored_data # pylint: disable=protected-access + authored_data = authored_data._authored_data else: authored_data = ReadOnlyFieldData(authored_data) diff --git a/lms/djangoapps/lms_xblock/test/test_runtime.py b/lms/djangoapps/lms_xblock/test/test_runtime.py index a3563e24d2..91aba728ac 100644 --- a/lms/djangoapps/lms_xblock/test/test_runtime.py +++ b/lms/djangoapps/lms_xblock/test/test_runtime.py @@ -9,7 +9,7 @@ from django.test import TestCase from mock import Mock, patch from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.locations import BlockUsageLocator, CourseLocator -from six.moves.urllib.parse import urlparse # pylint: disable=import-error +from six.moves.urllib.parse import urlparse from xblock.exceptions import NoSuchServiceError from xblock.fields import ScopeIds diff --git a/lms/djangoapps/lti_provider/apps.py b/lms/djangoapps/lti_provider/apps.py index 9360bbaf07..bb5a66f5ad 100644 --- a/lms/djangoapps/lti_provider/apps.py +++ b/lms/djangoapps/lti_provider/apps.py @@ -15,4 +15,4 @@ class LtiProviderConfig(AppConfig): def ready(self): # Import the tasks module to ensure that signal handlers are registered. - from . import signals # pylint: disable=unused-variable + from . import signals # pylint: disable=unused-import diff --git a/lms/djangoapps/mailing/management/commands/mailchimp_sync_course.py b/lms/djangoapps/mailing/management/commands/mailchimp_sync_course.py index cf736855c1..02d73c1c28 100644 --- a/lms/djangoapps/mailing/management/commands/mailchimp_sync_course.py +++ b/lms/djangoapps/mailing/management/commands/mailchimp_sync_course.py @@ -135,7 +135,7 @@ def get_student_data(students, exclude=None): """ # To speed the query, we won't retrieve the full User object, only # two of its values. The namedtuple simulates the User object. - FakeUser = namedtuple('Fake', 'id username is_anonymous') # pylint: disable=invalid-name + FakeUser = namedtuple('Fake', 'id username is_anonymous') exclude = exclude if exclude else set() diff --git a/lms/djangoapps/mobile_api/models.py b/lms/djangoapps/mobile_api/models.py index 3775cd58bb..8fe88fc9d1 100644 --- a/lms/djangoapps/mobile_api/models.py +++ b/lms/djangoapps/mobile_api/models.py @@ -91,7 +91,7 @@ class AppVersionConfig(models.Model): super(AppVersionConfig, self).save(*args, **kwargs) -class IgnoreMobileAvailableFlagConfig(ConfigurationModel): # pylint: disable=W5101 +class IgnoreMobileAvailableFlagConfig(ConfigurationModel): """ Configuration for the mobile_available flag. Default is false. diff --git a/lms/djangoapps/mobile_api/users/tests.py b/lms/djangoapps/mobile_api/users/tests.py index e06de0309f..cd3da9051a 100644 --- a/lms/djangoapps/mobile_api/users/tests.py +++ b/lms/djangoapps/mobile_api/users/tests.py @@ -16,7 +16,7 @@ from django.utils.timezone import now from milestones.tests.utils import MilestonesTestCaseMixin from mock import patch from six.moves import range -from six.moves.urllib.parse import parse_qs # pylint: disable=import-error +from six.moves.urllib.parse import parse_qs from course_modes.models import CourseMode from lms.djangoapps.courseware.access_response import MilestoneAccessError, StartDateError, VisibilityError diff --git a/lms/djangoapps/mobile_api/users/views.py b/lms/djangoapps/mobile_api/users/views.py index 135ba53600..68ace1c3fc 100644 --- a/lms/djangoapps/mobile_api/users/views.py +++ b/lms/djangoapps/mobile_api/users/views.py @@ -179,7 +179,7 @@ class UserCourseStatus(views.APIView): return self._get_course_info(request, course) @mobile_course_access(depth=2) - def get(self, request, course, *args, **kwargs): # pylint: disable=unused-argument + def get(self, request, course, *args, **kwargs): """ Get the ID of the module that the specified user last visited in the specified course. """ @@ -187,7 +187,7 @@ class UserCourseStatus(views.APIView): return self._get_course_info(request, course) @mobile_course_access(depth=2) - def patch(self, request, course, *args, **kwargs): # pylint: disable=unused-argument + def patch(self, request, course, *args, **kwargs): """ Update the ID of the module that the specified user last visited in the specified course. """ diff --git a/lms/djangoapps/program_enrollments/api/tests/test_linking.py b/lms/djangoapps/program_enrollments/api/tests/test_linking.py index 45664833c2..7979fe81a0 100644 --- a/lms/djangoapps/program_enrollments/api/tests/test_linking.py +++ b/lms/djangoapps/program_enrollments/api/tests/test_linking.py @@ -34,7 +34,7 @@ class TestLinkProgramEnrollmentsMixin(object): """ Utility methods and test data for testing linking """ @classmethod - def setUpTestData(cls): # pylint: disable=missing-docstring + def setUpTestData(cls): # pylint: disable=missing-function-docstring cls.program = uuid4() cls.curriculum = uuid4() cls.other_program = uuid4() diff --git a/lms/djangoapps/program_enrollments/apps.py b/lms/djangoapps/program_enrollments/apps.py index c2e56b0697..d4017b6e0d 100644 --- a/lms/djangoapps/program_enrollments/apps.py +++ b/lms/djangoapps/program_enrollments/apps.py @@ -29,5 +29,5 @@ class ProgramEnrollmentsConfig(AppConfig): """ Connect handlers to signals. """ - from . import signals # pylint: disable=unused-variable - from . import tasks # pylint: disable=unused-variable + from . import signals # pylint: disable=unused-import + from . import tasks # pylint: disable=unused-import diff --git a/lms/djangoapps/program_enrollments/management/commands/tests/test_migrate_saml_uids.py b/lms/djangoapps/program_enrollments/management/commands/tests/test_migrate_saml_uids.py index 2e83acf967..550e4c15c9 100644 --- a/lms/djangoapps/program_enrollments/management/commands/tests/test_migrate_saml_uids.py +++ b/lms/djangoapps/program_enrollments/management/commands/tests/test_migrate_saml_uids.py @@ -121,7 +121,7 @@ class TestMigrateSamlUids(TestCase): def test_learner_missed_by_mapping_file(self, mock_log): auth = UserSocialAuthFactory() # pylint disable required b/c this lint rule is confused about subfactories - email = auth.user.email # pylint: disable=no-member + email = auth.user.email new_urn = '9001' mock_info = mock_log.info @@ -162,7 +162,7 @@ class TestMigrateSamlUids(TestCase): @patch(_COMMAND_PATH + '.log') def test_learner_duplicated_in_mapping(self, mock_log): auth = UserSocialAuthFactory() - email = auth.user.email # pylint: disable=no-member + email = auth.user.email new_urn = '9001' mock_info = mock_log.info diff --git a/lms/djangoapps/program_enrollments/signals.py b/lms/djangoapps/program_enrollments/signals.py index 16949a8575..cd64c8278c 100644 --- a/lms/djangoapps/program_enrollments/signals.py +++ b/lms/djangoapps/program_enrollments/signals.py @@ -29,7 +29,7 @@ def _listen_for_lms_retire(sender, **kwargs): # pylint: disable=unused-argument @receiver(post_save, sender=UserSocialAuth) -def listen_for_social_auth_creation(sender, instance, created, **kwargs): # pylint: disable=unused-argument +def listen_for_social_auth_creation(sender, instance, created, **kwargs): """ Post-save signal that will attempt to link a social auth entry with waiting enrollments """ diff --git a/lms/djangoapps/shoppingcart/models.py b/lms/djangoapps/shoppingcart/models.py index 26c8d1f8f8..026f659c93 100644 --- a/lms/djangoapps/shoppingcart/models.py +++ b/lms/djangoapps/shoppingcart/models.py @@ -1747,7 +1747,7 @@ class CourseRegCodeItem(OrderItem): # file, but there's also a shared dependency on a random string generator which # is in another PR (for another feature) from lms.djangoapps.instructor.views.api import save_registration_code - for i in range(total_registration_codes): # pylint: disable=unused-variable + for i in range(total_registration_codes): save_registration_code(self.user, self.course_id, self.mode, order=self.order) log.info(u"Enrolled {0} in paid course {1}, paid ${2}" diff --git a/lms/djangoapps/shoppingcart/tests/test_views.py b/lms/djangoapps/shoppingcart/tests/test_views.py index 2dd37169d6..de4b08757f 100644 --- a/lms/djangoapps/shoppingcart/tests/test_views.py +++ b/lms/djangoapps/shoppingcart/tests/test_views.py @@ -26,7 +26,7 @@ from mock import Mock, patch from pytz import UTC from six import text_type from six.moves import range -from six.moves.urllib.parse import urlparse # pylint: disable=import-error +from six.moves.urllib.parse import urlparse from common.test.utils import XssTestMixin from course_modes.models import CourseMode @@ -750,7 +750,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin): self.assertEqual(resp.status_code, 200) self.assertEqual(self.cart.orderitem_set.count(), 1) info_log.assert_called_with( - 'Coupon "%s" redemption entry removed for user "%s" for order item "%s"', # pylint: disable=unicode-format-string + 'Coupon "%s" redemption entry removed for user "%s" for order item "%s"', self.coupon_code, self.user, str(reg_item.id) diff --git a/lms/djangoapps/static_template_view/views.py b/lms/djangoapps/static_template_view/views.py index 8d314e535a..d9ff099b5c 100644 --- a/lms/djangoapps/static_template_view/views.py +++ b/lms/djangoapps/static_template_view/views.py @@ -1,4 +1,4 @@ -# pylint: disable=missing-docstring,unused-argument +# pylint: disable=missing-module-docstring # View for semi-static templatized content. # diff --git a/lms/djangoapps/support/tests/test_refund.py b/lms/djangoapps/support/tests/test_refund.py index 51a50541d2..df763cb3ea 100644 --- a/lms/djangoapps/support/tests/test_refund.py +++ b/lms/djangoapps/support/tests/test_refund.py @@ -64,7 +64,6 @@ class RefundTests(ModuleStoreTestCase): super(RefundTests, self).tearDown() def _enroll(self, purchase=True): - # pylint: disable=missing-docstring CourseEnrollment.enroll(self.student, self.course_id, self.course_mode.mode_slug) if purchase: self.order = Order.get_cart_for_user(self.student) diff --git a/lms/djangoapps/support/views/index.py b/lms/djangoapps/support/views/index.py index 87a4d5e1c8..409177ac6d 100644 --- a/lms/djangoapps/support/views/index.py +++ b/lms/djangoapps/support/views/index.py @@ -57,7 +57,7 @@ SUPPORT_INDEX_URLS = [ @require_support_permission -def index(request): # pylint: disable=unused-argument +def index(request): """Render the support index view. """ context = { "urls": SUPPORT_INDEX_URLS diff --git a/lms/djangoapps/survey/apps.py b/lms/djangoapps/survey/apps.py index d1bd7b91c1..4cb55c84a9 100644 --- a/lms/djangoapps/survey/apps.py +++ b/lms/djangoapps/survey/apps.py @@ -17,4 +17,4 @@ class SurveyConfig(AppConfig): """ Connect signal handlers. """ - from . import signals # pylint: disable=unused-variable + from . import signals # pylint: disable=unused-import diff --git a/lms/djangoapps/survey/tests/factories.py b/lms/djangoapps/survey/tests/factories.py index f8f3bbf217..dedca7073a 100644 --- a/lms/djangoapps/survey/tests/factories.py +++ b/lms/djangoapps/survey/tests/factories.py @@ -1,6 +1,3 @@ -# pylint:disable=missing-docstring - - import factory from student.tests.factories import UserFactory diff --git a/lms/djangoapps/verify_student/apps.py b/lms/djangoapps/verify_student/apps.py index edf0b2035a..ec786b82c3 100644 --- a/lms/djangoapps/verify_student/apps.py +++ b/lms/djangoapps/verify_student/apps.py @@ -17,5 +17,5 @@ class VerifyStudentConfig(AppConfig): """ Connect signal handlers. """ - from . import signals # pylint: disable=unused-variable - from . import tasks # pylint: disable=unused-variable + from . import signals # pylint: disable=unused-import + from . import tasks # pylint: disable=unused-import diff --git a/lms/djangoapps/verify_student/message_types.py b/lms/djangoapps/verify_student/message_types.py index 2d55d04f1f..24097b434a 100644 --- a/lms/djangoapps/verify_student/message_types.py +++ b/lms/djangoapps/verify_student/message_types.py @@ -13,4 +13,4 @@ class VerificationExpiry(BaseMessageType): def __init__(self, *args, **kwargs): super(VerificationExpiry, self).__init__(*args, **kwargs) - self.options['transactional'] = True # pylint: disable=unsupported-assignment-operation + self.options['transactional'] = True diff --git a/lms/djangoapps/verify_student/tasks.py b/lms/djangoapps/verify_student/tasks.py index 4a9781d464..081e241f22 100644 --- a/lms/djangoapps/verify_student/tasks.py +++ b/lms/djangoapps/verify_student/tasks.py @@ -130,7 +130,7 @@ def send_request_to_ss_for_user(self, user_verification_id, copy_id_photo_from): 'response_ok': getattr(response, 'ok', False), 'response_text': getattr(response, 'text', '') } - except Exception as exc: # pylint: disable=bare-except + except Exception as exc: # pylint: disable=broad-except log.error( ( 'Retrying sending request to Software Secure for user: %r, Receipt ID: %r ' diff --git a/lms/djangoapps/verify_student/tests/test_views.py b/lms/djangoapps/verify_student/tests/test_views.py index ad7716333e..bd5555e253 100644 --- a/lms/djangoapps/verify_student/tests/test_views.py +++ b/lms/djangoapps/verify_student/tests/test_views.py @@ -11,9 +11,6 @@ import httpretty import mock import simplejson as json import six -import six.moves.urllib.error # pylint: disable=import-error -import six.moves.urllib.parse # pylint: disable=import-error -import six.moves.urllib.request # pylint: disable=import-error from bs4 import BeautifulSoup from django.conf import settings from django.core import mail diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index bab54f8fd2..5fdf0388a7 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -443,10 +443,10 @@ class PayAndVerifyView(View): # utm_params is [(u'utm_content', u'course-v1:IDBx IDB20.1x 1T2017'),... utm_params = [item for item in self.request.GET.items() if 'utm_' in item[0]] # utm_params is utm_content=course-v1%3AIDBx+IDB20.1x+1T2017&... - utm_params = six.moves.urllib.parse.urlencode(utm_params, True) # pylint: disable=too-many-function-args + utm_params = six.moves.urllib.parse.urlencode(utm_params, True) # utm_params is utm_content=course-v1:IDBx+IDB20.1x+1T2017&... # (course-keys do not have url encoding) - utm_params = six.moves.urllib.parse.unquote(utm_params) # pylint: disable=too-many-function-args + utm_params = six.moves.urllib.parse.unquote(utm_params) if utm_params: if '?' in url: url = url + '&' + utm_params diff --git a/lms/envs/common.py b/lms/envs/common.py index 220a988a22..5a6a81847e 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -26,7 +26,7 @@ Longer TODO: # 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, wrong-import-position +# pylint: disable=invalid-name import importlib.util @@ -527,7 +527,7 @@ RETRY_CALENDAR_SYNC_EMAIL_MAX_ATTEMPTS = 5 COURSE_MESSAGE_ALERT_DURATION_IN_DAYS = 14 ############################# SET PATH INFORMATION ############################# -PROJECT_ROOT = path(__file__).abspath().dirname().dirname() # /edx-platform/lms pylint: disable=no-value-for-parameter +PROJECT_ROOT = path(__file__).abspath().dirname().dirname() # /edx-platform/lms REPO_ROOT = PROJECT_ROOT.dirname() COMMON_ROOT = REPO_ROOT / "common" OPENEDX_ROOT = REPO_ROOT / "openedx" @@ -1331,7 +1331,7 @@ STATICI18N_OUTPUT_DIR = "js/i18n" # Localization strings (e.g. django.po) are under these directories -def _make_locale_paths(settings): # pylint: disable=missing-docstring +def _make_locale_paths(settings): # pylint: disable=missing-function-docstring locale_paths = [settings.REPO_ROOT + '/conf/locale'] # edx-platform/conf/locale/ if settings.ENABLE_COMPREHENSIVE_THEMING: # Add locale paths to settings for comprehensive theming. @@ -1345,7 +1345,8 @@ derived('LOCALE_PATHS') MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage' # Guidelines for translators -TRANSLATORS_GUIDE = 'https://edx.readthedocs.org/projects/edx-developer-guide/en/latest/conventions/internationalization/i18n_translators_guide.html' # pylint: disable=line-too-long +TRANSLATORS_GUIDE = 'https://edx.readthedocs.org/projects/edx-developer-guide/en/latest/' \ + 'conventions/internationalization/i18n_translators_guide.html' #################################### AWS ####################################### # S3BotoStorage insists on a timeout for uploaded assets. We should make it @@ -2080,7 +2081,8 @@ REQUIRE_JS_PATH_OVERRIDES = { 'js/student_account/logistration_factory': 'js/student_account/logistration_factory.js', 'js/courseware/courseware_factory': 'js/courseware/courseware_factory.js', 'js/groups/views/cohorts_dashboard_factory': 'js/groups/views/cohorts_dashboard_factory.js', - 'js/groups/discussions_management/discussions_dashboard_factory': 'js/discussions_management/views/discussions_dashboard_factory.js', # pylint: disable=line-too-long + 'js/groups/discussions_management/discussions_dashboard_factory': + 'js/discussions_management/views/discussions_dashboard_factory.js', 'draggabilly': 'js/vendor/draggabilly.js', 'hls': 'common/js/vendor/hls.js' } @@ -3363,7 +3365,8 @@ FIELD_OVERRIDE_PROVIDERS = () # Modulestore-level field override providers. These field override providers don't # require student context. -MODULESTORE_FIELD_OVERRIDE_PROVIDERS = ('openedx.features.content_type_gating.field_override.ContentTypeGatingFieldOverride',) # pylint: disable=line-too-long +MODULESTORE_FIELD_OVERRIDE_PROVIDERS = ('openedx.features.content_type_gating.' + 'field_override.ContentTypeGatingFieldOverride',) # PROFILE IMAGE CONFIG # WARNING: Certain django storage backends do not support atomic diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index 3ca490280b..238565540b 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -263,7 +263,6 @@ CORS_ALLOW_HEADERS = corsheaders_default_headers + ( LOGIN_REDIRECT_WHITELIST = [CMS_BASE] ###################### JWTs ###################### -# pylint: disable=unicode-format-string JWT_AUTH.update({ 'JWT_AUDIENCE': 'lms-key', 'JWT_ISSUER': '{}/oauth2'.format(LMS_ROOT_URL), diff --git a/lms/envs/test.py b/lms/envs/test.py index f0f2208803..e269776214 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -524,7 +524,6 @@ VIDEO_TRANSCRIPTS_SETTINGS = dict( ) ####################### Authentication Settings ########################## -# pylint: disable=unicode-format-string JWT_AUTH.update({ 'JWT_PUBLIC_SIGNING_JWK_SET': ( '{"keys": [{"kid": "BTZ9HA6K", "e": "AQAB", "kty": "RSA", "n": "o5cn3ljSRi6FaDEKTn0PS-oL9EFyv1pI7dRgffQLD1qf5D6' diff --git a/lms/wsgi.py b/lms/wsgi.py index d71a2c26eb..2893066edd 100644 --- a/lms/wsgi.py +++ b/lms/wsgi.py @@ -32,4 +32,4 @@ modulestore() # This application object is used by the development server # as well as any WSGI server configured to use this file. from django.core.wsgi import get_wsgi_application -application = get_wsgi_application() # pylint: disable=invalid-name +application = get_wsgi_application() diff --git a/openedx/core/djangoapps/django_comment_common/comment_client/settings.py b/openedx/core/djangoapps/django_comment_common/comment_client/settings.py index 4772e38c0d..f64726335f 100644 --- a/openedx/core/djangoapps/django_comment_common/comment_client/settings.py +++ b/openedx/core/djangoapps/django_comment_common/comment_client/settings.py @@ -1,6 +1,3 @@ -# pylint: disable=missing-docstring - - from django.conf import settings if hasattr(settings, "COMMENTS_SERVICE_URL"): diff --git a/openedx/features/enterprise_support/apps.py b/openedx/features/enterprise_support/apps.py index 515f931173..af8ee2539b 100644 --- a/openedx/features/enterprise_support/apps.py +++ b/openedx/features/enterprise_support/apps.py @@ -14,4 +14,4 @@ class EnterpriseSupportConfig(AppConfig): def ready(self): # Import signals to activate signal handler for enterprise. - from . import signals # pylint: disable=unused-variable + from . import signals # pylint: disable=unused-import diff --git a/pavelib/assets.py b/pavelib/assets.py index 61d3f52f2f..a421e933a4 100644 --- a/pavelib/assets.py +++ b/pavelib/assets.py @@ -285,11 +285,11 @@ def debounce(seconds=1): seconds. Waits until calls stop coming in before calling the decorated function. """ - def decorator(func): # pylint: disable=missing-docstring + def decorator(func): func.timer = None @wraps(func) - def wrapper(*args, **kwargs): # pylint: disable=missing-docstring + def wrapper(*args, **kwargs): def call(): func(*args, **kwargs) func.timer = None diff --git a/pavelib/paver_tests/test_paver_bok_choy_cmds.py b/pavelib/paver_tests/test_paver_bok_choy_cmds.py index 07a9274809..ff474f4c2e 100644 --- a/pavelib/paver_tests/test_paver_bok_choy_cmds.py +++ b/pavelib/paver_tests/test_paver_bok_choy_cmds.py @@ -11,7 +11,7 @@ import six if six.PY2: from test.test_support import EnvironmentVarGuard else: - from test.support import EnvironmentVarGuard # pylint: disable=import-error,no-name-in-module + from test.support import EnvironmentVarGuard from pavelib.utils.test.suites import BokChoyTestSuite diff --git a/pavelib/quality.py b/pavelib/quality.py index 9681e28a04..276f7ee2b4 100644 --- a/pavelib/quality.py +++ b/pavelib/quality.py @@ -1,4 +1,3 @@ -# pylint: disable=unicode-format-string # coding=utf-8 """ diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index 54e371bb0a..f08ccadad2 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -327,7 +327,7 @@ class Env(object): if not env_path.isfile(): print( u"Warning: could not find environment JSON file " - "at '{path}'".format(path=env_path), # pylint: disable=unicode-format-string + "at '{path}'".format(path=env_path), file=sys.stderr, ) return dict() @@ -340,7 +340,7 @@ class Env(object): except ValueError: print( u"Error: Could not parse JSON " - "in {path}".format(path=env_path), # pylint: disable=unicode-format-string + "in {path}".format(path=env_path), file=sys.stderr, ) sys.exit(1) diff --git a/pavelib/utils/test/suites/bokchoy_suite.py b/pavelib/utils/test/suites/bokchoy_suite.py index 5ca9c97e22..870291464d 100644 --- a/pavelib/utils/test/suites/bokchoy_suite.py +++ b/pavelib/utils/test/suites/bokchoy_suite.py @@ -1,4 +1,3 @@ -# pylint: disable=unicode-format-string """ Class used for defining and running Bok Choy acceptance test suite """ diff --git a/pavelib/utils/test/suites/pytest_suite.py b/pavelib/utils/test/suites/pytest_suite.py index c1c6f6c933..dad77ab916 100644 --- a/pavelib/utils/test/suites/pytest_suite.py +++ b/pavelib/utils/test/suites/pytest_suite.py @@ -1,4 +1,3 @@ -# pylint: disable=unicode-format-string """ Classes used for defining and running pytest test suites """ diff --git a/pavelib/utils/test/suites/suite.py b/pavelib/utils/test/suites/suite.py index c343074a37..aed2d58069 100644 --- a/pavelib/utils/test/suites/suite.py +++ b/pavelib/utils/test/suites/suite.py @@ -1,4 +1,3 @@ -# pylint: disable=unicode-format-string """ A class used for defining and running test suites """ diff --git a/pavelib/utils/test/utils.py b/pavelib/utils/test/utils.py index 5cb543670d..5bc84e0c3f 100644 --- a/pavelib/utils/test/utils.py +++ b/pavelib/utils/test/utils.py @@ -41,7 +41,7 @@ def clean_test_files(): # This find command removes all the *.pyc files that aren't in the .git # directory. See this blog post for more details: # http://nedbatchelder.com/blog/201505/be_careful_deleting_files_around_git.html - sh(r"find . -name '.git' -prune -o -name '*.pyc' -exec rm {} \;") # pylint: disable=unicode-format-string + sh(r"find . -name '.git' -prune -o -name '*.pyc' -exec rm {} \;") sh("rm -rf test_root/log/auto_screenshots/*") sh("rm -rf /tmp/mako_[cl]ms") diff --git a/scripts/thresholds.sh b/scripts/thresholds.sh index b10fbc1ad9..0d7e7da870 100755 --- a/scripts/thresholds.sh +++ b/scripts/thresholds.sh @@ -2,6 +2,6 @@ set -e export LOWER_PYLINT_THRESHOLD=1000 -export UPPER_PYLINT_THRESHOLD=3990 +export UPPER_PYLINT_THRESHOLD=3310 export ESLINT_THRESHOLD=5530 export STYLELINT_THRESHOLD=880