From 96f0915b0fbde221dadb0b37fba6f186894260b4 Mon Sep 17 00:00:00 2001 From: usamasadiq Date: Mon, 22 Feb 2021 12:42:26 +0500 Subject: [PATCH] Fixed new pylint warnings. use generator in any/all() disable not-callable warnings disable no-member warnings Suppressed smaller pylint warnings Pin edx-proctoring==3.5.0 --- cms/djangoapps/contentstore/views/item.py | 2 +- cms/djangoapps/contentstore/views/user.py | 2 +- common/djangoapps/student/email_helpers.py | 2 +- .../tests/test_bulk_change_enrollment_csv.py | 6 ++-- .../third_party_auth/api/permissions.py | 2 +- common/djangoapps/util/tests/test_db.py | 32 +++++++++---------- common/djangoapps/util/tests/test_file.py | 1 - .../lib/capa/capa/tests/test_responsetypes.py | 2 +- .../xmodule/xmodule/library_content_module.py | 2 +- .../xmodule/xmodule/modulestore/mongo/base.py | 2 +- .../xmodule/modulestore/mongo/draft.py | 2 +- .../modulestore/split_mongo/split_draft.py | 2 +- .../xmodule/modulestore/tests/factories.py | 2 +- .../modulestore/tests/test_semantics.py | 6 ++-- .../xmodule/xmodule/tests/test_conditional.py | 10 +++--- .../acceptance/pages/studio/pagination.py | 5 +-- common/test/acceptance/pages/studio/utils.py | 2 +- lms/djangoapps/certificates/apis/v0/views.py | 2 +- lms/djangoapps/courseware/date_summary.py | 4 +-- lms/djangoapps/discussion/rest_api/api.py | 2 +- lms/djangoapps/discussion/tests/test_views.py | 4 +-- lms/djangoapps/grades/config/models.py | 1 - lms/djangoapps/grades/course_data.py | 2 +- .../grades/rest_api/v1/gradebook_views.py | 1 - .../rest_api/v1/tests/test_gradebook_views.py | 1 - .../instructor/tests/test_services.py | 2 -- lms/djangoapps/instructor/tests/test_tools.py | 2 -- lms/djangoapps/instructor_task/views.py | 2 +- lms/djangoapps/mobile_api/models.py | 4 +-- lms/djangoapps/teams/views.py | 2 +- .../tests/test_generate_course_blocks.py | 2 +- openedx/core/djangoapps/dark_lang/tests.py | 2 +- .../discussions/tests/test_models.py | 2 +- .../django_comment_common/models.py | 2 +- openedx/core/djangoapps/theming/checks.py | 6 ++-- openedx/core/djangoapps/util/user_messages.py | 2 +- .../xblock_builtin/xblock_discussion/tests.py | 2 +- openedx/core/process_warnings.py | 7 ++-- openedx/features/course_experience/utils.py | 2 +- pavelib/paver_tests/test_pii_check.py | 12 +++---- requirements/constraints.txt | 3 ++ requirements/edx/base.txt | 2 +- requirements/edx/development.txt | 2 +- requirements/edx/testing.txt | 2 +- 44 files changed, 73 insertions(+), 86 deletions(-) diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index d9ed71c0ae..69f61537b0 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -1332,7 +1332,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F xblock_info['staff_only_message'] = True elif child_info and child_info['children']: xblock_info['staff_only_message'] = all( - [child['staff_only_message'] for child in child_info['children']] + child['staff_only_message'] for child in child_info['children'] ) else: xblock_info['staff_only_message'] = False diff --git a/cms/djangoapps/contentstore/views/user.py b/cms/djangoapps/contentstore/views/user.py index cc8acf5bb5..9bca938572 100644 --- a/cms/djangoapps/contentstore/views/user.py +++ b/cms/djangoapps/contentstore/views/user.py @@ -177,7 +177,7 @@ def _course_team_user(request, course_key, email): role_added = True else: return permissions_error_response - elif role.has_user(user, check_user_activation=False): + elif role.has_user(user, check_user_activation=False): # pylint: disable=no-value-for-parameter # Remove the user from this old role: old_roles.add(role) diff --git a/common/djangoapps/student/email_helpers.py b/common/djangoapps/student/email_helpers.py index c35739aa8d..cd7ccfe5fa 100644 --- a/common/djangoapps/student/email_helpers.py +++ b/common/djangoapps/student/email_helpers.py @@ -72,6 +72,6 @@ def should_send_proctoring_requirements_email(username, course_id): settings={'is_time_limited': True} ) - has_proctored_exam = any([exam.is_proctored_exam for exam in timed_exams]) + has_proctored_exam = any(exam.is_proctored_exam for exam in timed_exams) return has_proctored_exam diff --git a/common/djangoapps/student/management/tests/test_bulk_change_enrollment_csv.py b/common/djangoapps/student/management/tests/test_bulk_change_enrollment_csv.py index d106f971f4..67752ee05f 100644 --- a/common/djangoapps/student/management/tests/test_bulk_change_enrollment_csv.py +++ b/common/djangoapps/student/management/tests/test_bulk_change_enrollment_csv.py @@ -1,9 +1,9 @@ # lint-amnesty, pylint: disable=missing-module-docstring import unittest -import pytest from tempfile import NamedTemporaryFile +import pytest import six from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile @@ -13,13 +13,11 @@ from testfixtures import LogCapture from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.course_modes.tests.factories import CourseModeFactory -from common.djangoapps.student.models import CourseEnrollment +from common.djangoapps.student.models import BulkChangeEnrollmentConfiguration, CourseEnrollment from common.djangoapps.student.tests.factories import UserFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory -from common.djangoapps.student.models import BulkChangeEnrollmentConfiguration - LOGGER_NAME = 'common.djangoapps.student.management.commands.bulk_change_enrollment_csv' diff --git a/common/djangoapps/third_party_auth/api/permissions.py b/common/djangoapps/third_party_auth/api/permissions.py index b9b2423386..af7874c12b 100644 --- a/common/djangoapps/third_party_auth/api/permissions.py +++ b/common/djangoapps/third_party_auth/api/permissions.py @@ -52,7 +52,7 @@ class JwtHasTpaProviderFilterForRequestedProvider(BasePermission): # TODO: Remove ApiKeyHeaderPermission. Check deprecated_api_key_header custom attribute for active usage. _NOT_JWT_RESTRICTED_TPA_PERMISSIONS = ( C(NotJwtRestrictedApplication) & - (C(IsSuperuser) | ApiKeyHeaderPermission | C(IsStaff)) + (C(IsSuperuser) | ApiKeyHeaderPermission | C(IsStaff)) # pylint: disable=unsupported-binary-operation ) _JWT_RESTRICTED_TPA_PERMISSIONS = ( C(JwtRestrictedApplication) & diff --git a/common/djangoapps/util/tests/test_db.py b/common/djangoapps/util/tests/test_db.py index 303be00fd0..e1b67b6712 100644 --- a/common/djangoapps/util/tests/test_db.py +++ b/common/djangoapps/util/tests/test_db.py @@ -100,21 +100,21 @@ class TransactionManagersTestCase(TransactionTestCase): if connection.vendor != 'mysql': raise unittest.SkipTest('Only works on MySQL.') - outer_atomic()(do_nothing)() + outer_atomic()(do_nothing)() # pylint: disable=not-callable with atomic(): - atomic()(do_nothing)() + atomic()(do_nothing)() # pylint: disable=not-callable with outer_atomic(): - atomic()(do_nothing)() + atomic()(do_nothing)() # pylint: disable=not-callable with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with atomic(): - outer_atomic()(do_nothing)() + outer_atomic()(do_nothing)() # pylint: disable=not-callable with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with outer_atomic(): - outer_atomic()(do_nothing)() + outer_atomic()(do_nothing)() # pylint: disable=not-callable def test_named_outer_atomic_nesting(self): """ @@ -124,44 +124,44 @@ class TransactionManagersTestCase(TransactionTestCase): if connection.vendor != 'mysql': raise unittest.SkipTest('Only works on MySQL.') - outer_atomic(name='abc')(do_nothing)() + outer_atomic(name='abc')(do_nothing)() # pylint: disable=not-callable with atomic(): - outer_atomic(name='abc')(do_nothing)() + outer_atomic(name='abc')(do_nothing)() # pylint: disable=not-callable with enable_named_outer_atomic('abc'): - outer_atomic(name='abc')(do_nothing)() # Not nested. + outer_atomic(name='abc')(do_nothing)() # pylint: disable=not-callable # Not nested. with atomic(): - outer_atomic(name='pqr')(do_nothing)() # Not enabled. + outer_atomic(name='pqr')(do_nothing)() # pylint: disable=not-callable # Not enabled. with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with atomic(): - outer_atomic(name='abc')(do_nothing)() + outer_atomic(name='abc')(do_nothing)() # pylint: disable=not-callable with enable_named_outer_atomic('abc', 'def'): - outer_atomic(name='def')(do_nothing)() # Not nested. + outer_atomic(name='def')(do_nothing)() # pylint: disable=not-callable # Not nested. with atomic(): - outer_atomic(name='pqr')(do_nothing)() # Not enabled. + outer_atomic(name='pqr')(do_nothing)() # pylint: disable=not-callable # Not enabled. with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with atomic(): - outer_atomic(name='def')(do_nothing)() + outer_atomic(name='def')(do_nothing)() # pylint: disable=not-callable with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with outer_atomic(): - outer_atomic(name='def')(do_nothing)() + outer_atomic(name='def')(do_nothing)() # pylint: disable=not-callable with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with atomic(): - outer_atomic(name='abc')(do_nothing)() + outer_atomic(name='abc')(do_nothing)() # pylint: disable=not-callable with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with outer_atomic(): - outer_atomic(name='abc')(do_nothing)() + outer_atomic(name='abc')(do_nothing)() # pylint: disable=not-callable @ddt.ddt diff --git a/common/djangoapps/util/tests/test_file.py b/common/djangoapps/util/tests/test_file.py index 9e4f1bc467..4e391df539 100644 --- a/common/djangoapps/util/tests/test_file.py +++ b/common/djangoapps/util/tests/test_file.py @@ -9,7 +9,6 @@ from datetime import datetime from io import StringIO import pytest import ddt -import six from django.core import exceptions from django.core.files.uploadedfile import SimpleUploadedFile from django.http import HttpRequest diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index f86a47cef3..ec7146d9d6 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -1284,7 +1284,7 @@ class ChoiceResponseTest(ResponseTest): # pylint: disable=missing-class-docstri ok0 = c % 2 == 0 # check remainder modulo 2 ok1 = c % 3 == 0 # check remainder modulo 3 ok2 = c % 5 == 0 # check remainder modulo 5 - ok3 = not any([ok0, ok1, ok2]) + ok3 = not any((ok0, ok1, ok2)) """) choices = ["$ok0", "$ok1", "$ok2", "$ok3"] problem = self.build_problem(script=script, diff --git a/common/lib/xmodule/xmodule/library_content_module.py b/common/lib/xmodule/xmodule/library_content_module.py index 805caab06c..14136aadf3 100644 --- a/common/lib/xmodule/xmodule/library_content_module.py +++ b/common/lib/xmodule/xmodule/library_content_module.py @@ -228,7 +228,7 @@ class LibraryContentBlock( raise NotImplementedError("Unsupported mode.") selected_keys |= added_block_keys - if any([invalid_block_keys, overlimit_block_keys, added_block_keys]): + if any((invalid_block_keys, overlimit_block_keys, added_block_keys)): selected = list(selected_keys) random.shuffle(selected) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/base.py b/common/lib/xmodule/xmodule/modulestore/mongo/base.py index e7bebd5d55..e5e8f48323 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/base.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/base.py @@ -725,7 +725,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo results_by_url[location_url].setdefault('definition', {})['children'] = set(total_children) else: results_by_url[location_url] = result - if location.block_type == 'course': + if location.block_type == 'course': # pylint: disable=no-member root = location_url # now traverse the tree and compute down the inherited metadata diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/draft.py b/common/lib/xmodule/xmodule/modulestore/mongo/draft.py index 39966d4796..3f2dc91f34 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/draft.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/draft.py @@ -679,7 +679,7 @@ class DraftModuleStore(MongoModuleStore): # fix a bug where dangling pointers should imply a change if len(xblock.children) > len(xblock.get_children()): return True - return any([self.has_changes(child) for child in xblock.get_children()]) + return any(self.has_changes(child) for child in xblock.get_children()) # otherwise there are no changes else: return False 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 13e2ab9f46..ea21a195b7 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py @@ -361,7 +361,7 @@ class DraftVersioningModuleStore(SplitMongoModuleStore, ModuleStoreDraftAndPubli # check the children in the draft if 'children' in draft_block.fields: return any( - [has_changes_subtree(child_block_id) for child_block_id in draft_block.fields['children']] + has_changes_subtree(child_block_id) for child_block_id in draft_block.fields['children'] ) return False diff --git a/common/lib/xmodule/xmodule/modulestore/tests/factories.py b/common/lib/xmodule/xmodule/modulestore/tests/factories.py index 2514aa1d10..56ea6cf276 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/factories.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/factories.py @@ -626,7 +626,7 @@ def mongo_uses_error_check(store): Does mongo use the error check as a separate message? """ if hasattr(store, 'modulestores'): - return any([mongo_uses_error_check(substore) for substore in store.modulestores]) + return any(mongo_uses_error_check(substore) for substore in store.modulestores) return False diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_semantics.py b/common/lib/xmodule/xmodule/modulestore/tests/test_semantics.py index 0dcb2c9049..ba667f8588 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_semantics.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_semantics.py @@ -214,9 +214,9 @@ class DirectOnlyCategorySemantics(PureModulestoreTestCase): def verify_course_summery_fields(course_summary): """ Verify that every `course_summary` object has all the required fields """ expected_fields = CourseSummary.course_info_fields + ['id', 'location', 'has_ended'] - return all([hasattr(course_summary, field) for field in expected_fields]) + return all(hasattr(course_summary, field) for field in expected_fields) - assert all((verify_course_summery_fields(course_summary) for course_summary in course_summaries)) + assert all(verify_course_summery_fields(course_summary) for course_summary in course_summaries) def is_detached(self, block_type): """ @@ -236,7 +236,7 @@ class DirectOnlyCategorySemantics(PureModulestoreTestCase): field_data = KvsFieldData(key_store) 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) + aside.fields[self.ASIDE_DATA_FIELD.field_name].write_to(aside, self.ASIDE_DATA_FIELD.initial) # pylint: disable=unsubscriptable-object return [aside] def _get_aside(self, block): diff --git a/common/lib/xmodule/xmodule/tests/test_conditional.py b/common/lib/xmodule/xmodule/tests/test_conditional.py index 83ed4cde39..02d2a746f8 100644 --- a/common/lib/xmodule/xmodule/tests/test_conditional.py +++ b/common/lib/xmodule/xmodule/tests/test_conditional.py @@ -180,7 +180,7 @@ class ConditionalBlockBasicTest(unittest.TestCase): ajax = json.loads(modules['cond_module'].handle_ajax('', '')) print("ajax: ", ajax) fragments = ajax['fragments'] - assert not any([('This is a secret' in item['content']) for item in fragments]) + assert not any(('This is a secret' in item['content']) for item in fragments) # now change state of the capa problem to make it completed modules['source_module'].is_attempted = "true" @@ -188,7 +188,7 @@ class ConditionalBlockBasicTest(unittest.TestCase): modules['cond_module'].save() print("post-attempt ajax: ", ajax) fragments = ajax['fragments'] - assert any([('This is a secret' in item['content']) for item in fragments]) + assert any(('This is a secret' in item['content']) for item in fragments) def test_error_as_source(self): ''' @@ -199,7 +199,7 @@ class ConditionalBlockBasicTest(unittest.TestCase): modules['cond_module'].save() ajax = json.loads(modules['cond_module'].handle_ajax('', '')) fragments = ajax['fragments'] - assert not any([('This is a secret' in item['content']) for item in fragments]) + assert not any(('This is a secret' in item['content']) for item in fragments) @patch('xmodule.conditional_module.log') def test_conditional_with_staff_only_source_module(self, mock_log): @@ -294,7 +294,7 @@ class ConditionalBlockXmlTest(unittest.TestCase): module.save() print("ajax: ", ajax) fragments = ajax['fragments'] - assert not any([('This is a secret' in item['content']) for item in fragments]) + assert not any(('This is a secret' in item['content']) for item in fragments) # Now change state of the capa problem to make it completed inner_module = inner_get_module(location.replace(category="problem", name='choiceprob')) @@ -306,7 +306,7 @@ class ConditionalBlockXmlTest(unittest.TestCase): module.save() print("post-attempt ajax: ", ajax) fragments = ajax['fragments'] - assert any([('This is a secret' in item['content']) for item in fragments]) + assert any(('This is a secret' in item['content']) for item in fragments) maxDiff = None diff --git a/common/test/acceptance/pages/studio/pagination.py b/common/test/acceptance/pages/studio/pagination.py index 8440d1d116..a7bdc7ddf0 100644 --- a/common/test/acceptance/pages/studio/pagination.py +++ b/common/test/acceptance/pages/studio/pagination.py @@ -18,10 +18,7 @@ class PaginatedMixin(object): To specify a specific arrow, pass an iterable with a single element, 'next' or 'previous'. """ - return all([ - self.q(css=u'nav.%s * .%s-page-link.is-disabled' % (position, arrow)) - for arrow in arrows - ]) + return all(self.q(css=u'nav.%s * .%s-page-link.is-disabled' % (position, arrow)) for arrow in arrows) def move_back(self, position): """ diff --git a/common/test/acceptance/pages/studio/utils.py b/common/test/acceptance/pages/studio/utils.py index bc60f5c7fa..714a6d7e28 100644 --- a/common/test/acceptance/pages/studio/utils.py +++ b/common/test/acceptance/pages/studio/utils.py @@ -56,7 +56,7 @@ def set_input_value_and_save(page, css, value): page.wait_for_ajax() -def verify_ordering(test_class, page, expected_orderings): +def verify_ordering(test_class, page, expected_orderings): # pylint: disable=unused-argument """ Verifies the expected ordering of xblocks on the page. """ diff --git a/lms/djangoapps/certificates/apis/v0/views.py b/lms/djangoapps/certificates/apis/v0/views.py index ad23ff36d5..4df0800993 100644 --- a/lms/djangoapps/certificates/apis/v0/views.py +++ b/lms/djangoapps/certificates/apis/v0/views.py @@ -159,7 +159,7 @@ class CertificatesListView(APIView): permissions.JwtHasUserFilterForRequestedUser ) ), - (C(permissions.IsStaff) | IsOwnerOrPublicCertificates), + (C(permissions.IsStaff) | IsOwnerOrPublicCertificates), # pylint: disable=unsupported-binary-operation ) required_scopes = ['certificates:read'] diff --git a/lms/djangoapps/courseware/date_summary.py b/lms/djangoapps/courseware/date_summary.py index ec0e3238e1..79e5ec0585 100644 --- a/lms/djangoapps/courseware/date_summary.py +++ b/lms/djangoapps/courseware/date_summary.py @@ -491,11 +491,11 @@ class CertificateAvailableDate(DateSummary): @property def has_certificate_modes(self): - return any([ + return any( mode.slug for mode in CourseMode.modes_for_course( course_id=self.course.id, include_expired=True ) if mode.slug != CourseMode.AUDIT - ]) + ) def register_alerts(self, request, course): """ diff --git a/lms/djangoapps/discussion/rest_api/api.py b/lms/djangoapps/discussion/rest_api/api.py index f56e895569..0f8fac0396 100644 --- a/lms/djangoapps/discussion/rest_api/api.py +++ b/lms/djangoapps/discussion/rest_api/api.py @@ -103,7 +103,7 @@ def _get_course(course_key, user): # Raise course not found if the user cannot access the course # since it doesn't make sense to redirect an API. raise CourseNotFoundError("Course not found.") # lint-amnesty, pylint: disable=raise-missing-from - if not any([tab.type == 'discussion' and tab.is_enabled(course, user) for tab in course.tabs]): + if not any(tab.type == 'discussion' and tab.is_enabled(course, user) for tab in course.tabs): raise DiscussionDisabledError("Discussion is disabled for the course.") return course diff --git a/lms/djangoapps/discussion/tests/test_views.py b/lms/djangoapps/discussion/tests/test_views.py index ae8e1b43cd..eaf240c1ca 100644 --- a/lms/djangoapps/discussion/tests/test_views.py +++ b/lms/djangoapps/discussion/tests/test_views.py @@ -293,10 +293,10 @@ class PartialDictMatcher: # lint-amnesty, pylint: disable=missing-class-docstri self.expected_values = expected_values def __eq__(self, other): - return all([ + return all( key in other and other[key] == value for key, value in self.expected_values.items() - ]) + ) @patch('requests.request', autospec=True) diff --git a/lms/djangoapps/grades/config/models.py b/lms/djangoapps/grades/config/models.py index 8a6b909181..50eb03264c 100644 --- a/lms/djangoapps/grades/config/models.py +++ b/lms/djangoapps/grades/config/models.py @@ -9,7 +9,6 @@ from django.conf import settings from django.db.models import BooleanField, IntegerField, TextField from django.utils.encoding import python_2_unicode_compatible from opaque_keys.edx.django.models import CourseKeyField -from six import text_type from openedx.core.lib.cache_utils import request_cached diff --git a/lms/djangoapps/grades/course_data.py b/lms/djangoapps/grades/course_data.py index 791758138c..db121f7a28 100644 --- a/lms/djangoapps/grades/course_data.py +++ b/lms/djangoapps/grades/course_data.py @@ -23,7 +23,7 @@ class CourseData: cache during its lifecycle. """ def __init__(self, user, course=None, collected_block_structure=None, structure=None, course_key=None): - if not any([course, collected_block_structure, structure, course_key]): + if not any((course, collected_block_structure, structure, course_key)): raise ValueError( "You must specify one of course, collected_block_structure, structure, or course_key to this method." ) diff --git a/lms/djangoapps/grades/rest_api/v1/gradebook_views.py b/lms/djangoapps/grades/rest_api/v1/gradebook_views.py index e8a4224eb6..778f8a2e26 100644 --- a/lms/djangoapps/grades/rest_api/v1/gradebook_views.py +++ b/lms/djangoapps/grades/rest_api/v1/gradebook_views.py @@ -19,7 +19,6 @@ from rest_framework import status from rest_framework.generics import GenericAPIView from rest_framework.response import Response from rest_framework.views import APIView -from six import text_type from common.djangoapps.student.auth import has_course_author_access from common.djangoapps.student.models import CourseEnrollment diff --git a/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py b/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py index f861e60fc7..3aceb2878e 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py @@ -17,7 +17,6 @@ from opaque_keys.edx.locator import BlockUsageLocator from pytz import UTC from rest_framework import status from rest_framework.test import APITestCase -from six import text_type from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory diff --git a/lms/djangoapps/instructor/tests/test_services.py b/lms/djangoapps/instructor/tests/test_services.py index e8ea894900..ba298934ee 100644 --- a/lms/djangoapps/instructor/tests/test_services.py +++ b/lms/djangoapps/instructor/tests/test_services.py @@ -5,8 +5,6 @@ import json from unittest import mock import pytest -import mock -import six from django.core.exceptions import ObjectDoesNotExist from opaque_keys import InvalidKeyError diff --git a/lms/djangoapps/instructor/tests/test_tools.py b/lms/djangoapps/instructor/tests/test_tools.py index 0ad231bf21..2ad4579e00 100644 --- a/lms/djangoapps/instructor/tests/test_tools.py +++ b/lms/djangoapps/instructor/tests/test_tools.py @@ -9,8 +9,6 @@ import unittest from unittest import mock import pytest -import mock -import six from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import MultipleObjectsReturned from django.test import TestCase diff --git a/lms/djangoapps/instructor_task/views.py b/lms/djangoapps/instructor_task/views.py index cb2987156a..ada463600c 100644 --- a/lms/djangoapps/instructor_task/views.py +++ b/lms/djangoapps/instructor_task/views.py @@ -120,7 +120,7 @@ def get_task_completion_info(instructor_task): # lint-amnesty, pylint: disable= if instructor_task.task_state in [FAILURE, REVOKED]: return (succeeded, task_output.get('message', _('No message provided'))) - if any([key not in task_output for key in ['action_name', 'attempted', 'total']]): + if any(key not in task_output for key in ['action_name', 'attempted', 'total']): fmt = _("Invalid task_output information found for instructor_task {0}: {1}") log.warning(fmt.format(instructor_task.task_id, instructor_task.task_output)) return (succeeded, _("No progress status information available")) diff --git a/lms/djangoapps/mobile_api/models.py b/lms/djangoapps/mobile_api/models.py index 61c6a815d2..777f9cd511 100644 --- a/lms/djangoapps/mobile_api/models.py +++ b/lms/djangoapps/mobile_api/models.py @@ -43,9 +43,7 @@ class AppVersionConfig(models.Model): .. no_pii: """ - PLATFORM_CHOICES = tuple( - [(platform, platform) for platform in sorted(PLATFORM_CLASSES.keys())] - ) + PLATFORM_CHOICES = tuple((platform, platform) for platform in sorted(PLATFORM_CLASSES.keys())) platform = models.CharField(max_length=50, choices=PLATFORM_CHOICES, blank=False) version = models.CharField( diff --git a/lms/djangoapps/teams/views.py b/lms/djangoapps/teams/views.py index 73dd836bc6..896dc7f9b5 100644 --- a/lms/djangoapps/teams/views.py +++ b/lms/djangoapps/teams/views.py @@ -159,7 +159,7 @@ class TeamsDashboardView(GenericAPIView): 'organization_protection_status': organization_protection_status }, ) - topics_data["sort_order"] = sort_order + topics_data["sort_order"] = sort_order # pylint: disable=unsupported-assignment-operation filter_query = { 'membership__user': user, diff --git a/openedx/core/djangoapps/content/block_structure/management/commands/tests/test_generate_course_blocks.py b/openedx/core/djangoapps/content/block_structure/management/commands/tests/test_generate_course_blocks.py index 38d74994a9..33ebecf296 100644 --- a/openedx/core/djangoapps/content/block_structure/management/commands/tests/test_generate_course_blocks.py +++ b/openedx/core/djangoapps/content/block_structure/management/commands/tests/test_generate_course_blocks.py @@ -69,7 +69,7 @@ class TestGenerateCourseBlocks(ModuleStoreTestCase): """ Asserts that the logger was called with the given message. """ - message_present = any([message in call_args[0][0] for call_args in mock_log.warning.call_args_list]) + message_present = any(message in call_args[0][0] for call_args in mock_log.warning.call_args_list) if expected_presence: assert message_present else: diff --git a/openedx/core/djangoapps/dark_lang/tests.py b/openedx/core/djangoapps/dark_lang/tests.py index 93384b7f19..6c3a4ff6c3 100644 --- a/openedx/core/djangoapps/dark_lang/tests.py +++ b/openedx/core/djangoapps/dark_lang/tests.py @@ -227,7 +227,7 @@ class DarkLangMiddlewareTests(CacheIsolationTestCase): self.assertAcceptEquals( 'es-419;q=1.0', - self.process_middleware_request(accept=b'{};q=1.0, pt;q=0.5'.format(latin_america_code)) + self.process_middleware_request(accept=b'{};q=1.0, pt;q=0.5'.format(latin_america_code)) # pylint:disable=no-member ) def assert_session_lang_equals(self, value, session): diff --git a/openedx/core/djangoapps/discussions/tests/test_models.py b/openedx/core/djangoapps/discussions/tests/test_models.py index d19f9fbfb3..5d987401c0 100644 --- a/openedx/core/djangoapps/discussions/tests/test_models.py +++ b/openedx/core/djangoapps/discussions/tests/test_models.py @@ -173,7 +173,7 @@ class DiscussionsConfigurationModelTest(TestCase): assert not configuration.enabled assert configuration.lti_configuration is None actual_url = configuration.plugin_configuration.get('url') - expected_url = self.configuration_with_values.plugin_configuration.get('url') + expected_url = self.configuration_with_values.plugin_configuration.get('url') # pylint: disable=no-member assert actual_url == expected_url assert configuration.provider_type == self.configuration_with_values.provider_type diff --git a/openedx/core/djangoapps/django_comment_common/models.py b/openedx/core/djangoapps/django_comment_common/models.py index b5c7aeef04..5bc99a2320 100644 --- a/openedx/core/djangoapps/django_comment_common/models.py +++ b/openedx/core/djangoapps/django_comment_common/models.py @@ -158,7 +158,7 @@ def permission_blacked_out(course, role_names, permission_name): return ( not course.forum_posts_allowed and role_names == {FORUM_ROLE_STUDENT} and - any([permission_name.startswith(prefix) for prefix in ['edit', 'update', 'create']]) + any(permission_name.startswith(prefix) for prefix in ['edit', 'update', 'create']) ) diff --git a/openedx/core/djangoapps/theming/checks.py b/openedx/core/djangoapps/theming/checks.py index 7846b5500b..54a43ab597 100644 --- a/openedx/core/djangoapps/theming/checks.py +++ b/openedx/core/djangoapps/theming/checks.py @@ -55,7 +55,7 @@ def check_comprehensive_theme_settings(app_configs, **kwargs): # lint-amnesty, id='openedx.core.djangoapps.theming.E004', ) ) - if not all([isinstance(theme_dir, six.string_types) for theme_dir in theme_dirs]): + if not all(isinstance(theme_dir, six.string_types) for theme_dir in theme_dirs): errors.append( Error( "COMPREHENSIVE_THEME_DIRS must contain only strings.", @@ -63,7 +63,7 @@ def check_comprehensive_theme_settings(app_configs, **kwargs): # lint-amnesty, id='openedx.core.djangoapps.theming.E005', ) ) - if not all([theme_dir.startswith("/") for theme_dir in theme_dirs]): + if not all(theme_dir.startswith("/") for theme_dir in theme_dirs): errors.append( Error( "COMPREHENSIVE_THEME_DIRS must contain only absolute paths to themes dirs.", @@ -71,7 +71,7 @@ def check_comprehensive_theme_settings(app_configs, **kwargs): # lint-amnesty, id='openedx.core.djangoapps.theming.E006', ) ) - if not all([os.path.isdir(theme_dir) for theme_dir in theme_dirs]): + if not all(os.path.isdir(theme_dir) for theme_dir in theme_dirs): errors.append( Error( "COMPREHENSIVE_THEME_DIRS must contain valid paths.", diff --git a/openedx/core/djangoapps/util/user_messages.py b/openedx/core/djangoapps/util/user_messages.py index 84ad806dba..edd37fba97 100644 --- a/openedx/core/djangoapps/util/user_messages.py +++ b/openedx/core/djangoapps/util/user_messages.py @@ -164,7 +164,7 @@ class UserMessageCollection(): """ Returns the user message type associated with a level. """ - for __, type in UserMessageType.__members__.items(): # lint-amnesty, pylint: disable=redefined-builtin + for __, type in UserMessageType.__members__.items(): # lint-amnesty, pylint: disable=redefined-builtin, no-member if type.value is level: return type raise Exception(u'Unable to find UserMessageType for level {level}'.format(level=level)) diff --git a/openedx/core/lib/xblock_builtin/xblock_discussion/tests.py b/openedx/core/lib/xblock_builtin/xblock_discussion/tests.py index 306f8d10fa..e6e5c409f5 100644 --- a/openedx/core/lib/xblock_builtin/xblock_discussion/tests.py +++ b/openedx/core/lib/xblock_builtin/xblock_discussion/tests.py @@ -160,7 +160,7 @@ class DiscussionXBlockImportExportTests(TestCase): target_node = etree.Element('dummy') block = DiscussionXBlock(self.runtime_mock, scope_ids=self.keys, field_data=DictFieldData({})) - discussion_id_field = block.fields['discussion_id'] + discussion_id_field = block.fields['discussion_id'] # pylint: disable=unsubscriptable-object # precondition checks - discussion_id does not have a value and uses UNIQUE_ID self.assertEqual( diff --git a/openedx/core/process_warnings.py b/openedx/core/process_warnings.py index 8c712d64cc..fb6a3da738 100644 --- a/openedx/core/process_warnings.py +++ b/openedx/core/process_warnings.py @@ -1,4 +1,5 @@ -""" # lint-amnesty, pylint: disable=django-not-configured +# lint-amnesty, pylint: disable=django-not-configured +""" Script to process pytest warnings output by pytest-json-report plugin and output it as a html """ @@ -10,9 +11,7 @@ import os import re from collections import Counter -from write_to_html import ( - HtmlOutlineWriter, -) # noqa pylint: disable=import-error,useless-suppression +from write_to_html import HtmlOutlineWriter # noqa pylint: disable=import-error,useless-suppression columns = [ "message", diff --git a/openedx/features/course_experience/utils.py b/openedx/features/course_experience/utils.py index 4df5f342a3..29104d595a 100644 --- a/openedx/features/course_experience/utils.py +++ b/openedx/features/course_experience/utils.py @@ -141,7 +141,7 @@ def get_course_outline_block_tree(request, course_id, user=None, allow_start_dat is_scored = block.get('has_score', False) and block.get('weight', 1) > 0 # Use a list comprehension to force the recursion over all children, rather than just stopping # at the first child that is scored. - children_scored = any([recurse_mark_scored(child) for child in block.get('children', [])]) + children_scored = any(recurse_mark_scored(child) for child in block.get('children', [])) if is_scored or children_scored: block['scored'] = True return True diff --git a/pavelib/paver_tests/test_pii_check.py b/pavelib/paver_tests/test_pii_check.py index 46115274aa..ad4b0a8c94 100644 --- a/pavelib/paver_tests/test_pii_check.py +++ b/pavelib/paver_tests/test_pii_check.py @@ -40,9 +40,9 @@ class TestPaverPIICheck(unittest.TestCase): call_task('pavelib.quality.run_pii_check', options={"report_dir": str(self.report_dir)}) mock_calls = [str(call) for call in mock_paver_sh.mock_calls] assert len(mock_calls) == 2 - assert any(['lms.envs.test' in call for call in mock_calls]) - assert any(['cms.envs.test' in call for call in mock_calls]) - assert all([str(self.report_dir) in call for call in mock_calls]) + assert any('lms.envs.test' in call for call in mock_calls) + assert any('cms.envs.test' in call for call in mock_calls) + assert all(str(self.report_dir) in call for call in mock_calls) metrics_file = Env.METRICS_DIR / 'pii' assert open(metrics_file, 'r').read() == 'Number of PII Annotation violations: 66\n' @@ -67,8 +67,8 @@ class TestPaverPIICheck(unittest.TestCase): self.assertRaises(BuildFailure) mock_calls = [str(call) for call in mock_paver_sh.mock_calls] assert len(mock_calls) == 2 - assert any(['lms.envs.test' in call for call in mock_calls]) - assert any(['cms.envs.test' in call for call in mock_calls]) - assert all([str(self.report_dir) in call for call in mock_calls]) + assert any('lms.envs.test' in call for call in mock_calls) + assert any('cms.envs.test' in call for call in mock_calls) + assert all(str(self.report_dir) in call for call in mock_calls) metrics_file = Env.METRICS_DIR / 'pii' assert open(metrics_file, 'r').read() == 'Number of PII Annotation violations: 66\n' diff --git a/requirements/constraints.txt b/requirements/constraints.txt index adf571a0ce..d3dc4edd64 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -123,3 +123,6 @@ edx-bulk-grades<0.8.5 # python3-saml==1.10.0 version started breaking a11y tests python3-saml<1.10.0 + +# edx-proctoring>3.5.0 causes test failures +edx-proctoring==3.5.0 diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 60a30604cb..e08317bed2 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -106,7 +106,7 @@ edx-milestones==0.3.0 # via -r requirements/edx/base.in edx-opaque-keys[django]==2.2.0 # via -r requirements/edx/paver.txt, edx-bulk-grades, edx-ccx-keys, edx-completion, edx-drf-extensions, edx-enterprise, edx-milestones, edx-organizations, edx-proctoring, edx-user-state-client, edx-when, lti-consumer-xblock, xmodule edx-organizations==6.9.0 # via -r requirements/edx/base.in edx-proctoring-proctortrack==1.0.5 # via -r requirements/edx/base.in -edx-proctoring==3.6.0 # via -r requirements/edx/base.in, edx-proctoring-proctortrack +edx-proctoring==3.5.0 # via -r requirements/edx/base.in, edx-proctoring-proctortrack edx-rbac==1.4.1 # via edx-enterprise edx-rest-api-client==5.3.0 # via -r requirements/edx/base.in, edx-enterprise, edx-proctoring edx-search==3.0.0 # via -r requirements/edx/base.in diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 18f9358e89..5301d29544 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -118,7 +118,7 @@ edx-milestones==0.3.0 # via -r requirements/edx/testing.txt edx-opaque-keys[django]==2.2.0 # via -r requirements/edx/testing.txt, edx-bulk-grades, edx-ccx-keys, edx-completion, edx-drf-extensions, edx-enterprise, edx-milestones, edx-organizations, edx-proctoring, edx-user-state-client, edx-when, lti-consumer-xblock, xmodule edx-organizations==6.9.0 # via -r requirements/edx/testing.txt edx-proctoring-proctortrack==1.0.5 # via -r requirements/edx/testing.txt -edx-proctoring==3.6.0 # via -r requirements/edx/testing.txt, edx-proctoring-proctortrack +edx-proctoring==3.5.0 # via -r requirements/edx/testing.txt, edx-proctoring-proctortrack edx-rbac==1.4.1 # via -r requirements/edx/testing.txt, edx-enterprise edx-rest-api-client==5.3.0 # via -r requirements/edx/testing.txt, edx-enterprise, edx-proctoring edx-search==3.0.0 # via -r requirements/edx/testing.txt diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index ffbfe8e372..728d1f4f1f 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -115,7 +115,7 @@ edx-milestones==0.3.0 # via -r requirements/edx/base.txt edx-opaque-keys[django]==2.2.0 # via -r requirements/edx/base.txt, edx-bulk-grades, edx-ccx-keys, edx-completion, edx-drf-extensions, edx-enterprise, edx-milestones, edx-organizations, edx-proctoring, edx-user-state-client, edx-when, lti-consumer-xblock, xmodule edx-organizations==6.9.0 # via -r requirements/edx/base.txt edx-proctoring-proctortrack==1.0.5 # via -r requirements/edx/base.txt -edx-proctoring==3.6.0 # via -r requirements/edx/base.txt, edx-proctoring-proctortrack +edx-proctoring==3.5.0 # via -r requirements/edx/base.txt, edx-proctoring-proctortrack edx-rbac==1.4.1 # via -r requirements/edx/base.txt, edx-enterprise edx-rest-api-client==5.3.0 # via -r requirements/edx/base.txt, edx-enterprise, edx-proctoring edx-search==3.0.0 # via -r requirements/edx/base.txt