diff --git a/cms/djangoapps/contentstore/api/views/course_quality.py b/cms/djangoapps/contentstore/api/views/course_quality.py index 7b2585f50f3c..05d5ecfd216f 100644 --- a/cms/djangoapps/contentstore/api/views/course_quality.py +++ b/cms/djangoapps/contentstore/api/views/course_quality.py @@ -255,10 +255,7 @@ def leaf_filter(block): len(cls._get_children(block)) == 0 ) - return [ - block for block in # lint-amnesty, pylint: disable=unnecessary-comprehension - traverse_pre_order(unit, cls._get_visible_children, leaf_filter) - ] + return list(traverse_pre_order(unit, cls._get_visible_children, leaf_filter)) def _stats_dict(self, data): # lint-amnesty, pylint: disable=missing-function-docstring if not data: diff --git a/common/djangoapps/student/management/commands/bulk_update_email.py b/common/djangoapps/student/management/commands/bulk_update_email.py index 4847b1a689df..e5c191a0ad12 100644 --- a/common/djangoapps/student/management/commands/bulk_update_email.py +++ b/common/djangoapps/student/management/commands/bulk_update_email.py @@ -46,12 +46,7 @@ def handle(self, *args, **options): with open(file_path) as csv_file: csv_reader = csv.reader(csv_file) - - email_mappings = [ - (current_email, new_email) - for (current_email, new_email) # lint-amnesty, pylint: disable=unnecessary-comprehension - in csv_reader - ] + email_mappings = list(csv_reader) successful_updates = [] failed_updates = [] diff --git a/common/lib/symmath/symmath/test_symmath_check.py b/common/lib/symmath/symmath/test_symmath_check.py index b611cfe36fa0..5a3cfe85f494 100644 --- a/common/lib/symmath/symmath/test_symmath_check.py +++ b/common/lib/symmath/symmath/test_symmath_check.py @@ -8,7 +8,7 @@ class SymmathCheckTest(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring def test_symmath_check_integers(self): - number_list = [i for i in range(-100, 100)] # lint-amnesty, pylint: disable=unnecessary-comprehension + number_list = range(-100, 100) self._symmath_check_numbers(number_list) def test_symmath_check_floats(self): 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 1d806e4706b5..dad838bc2783 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 @@ -194,7 +194,7 @@ def test_asset_sizes(self, source_ms, num_assets): results = asset_collection.map_reduce(mapper, reducer, "size_results") result_str = "{} - Store: {:<15} - Num Assets: {:>6} - Result: {}\n".format( - self.test_run_time, SHORT_NAME_MAP[source_ms], num_assets, [r for r in results.find()] # lint-amnesty, pylint: disable=unnecessary-comprehension + self.test_run_time, SHORT_NAME_MAP[source_ms], num_assets, results.find() ) with open("bson_sizes.txt", "a") as f: f.write(result_str) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py b/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py index 908ad97baa61..2220de8ce548 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py @@ -402,7 +402,7 @@ def setUp(self): for Django ORM models that will get cleaned up properly. """ # Tell Django to clean out all databases, not just default - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) @classmethod @contextmanager @@ -491,7 +491,7 @@ class FooTest(ModuleStoreTestCase): CREATE_USER = True # Tell Django to clean out all databases, not just default - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) @classmethod def setUpClass(cls): diff --git a/common/lib/xmodule/xmodule/tests/test_import.py b/common/lib/xmodule/xmodule/tests/test_import.py index 1f2fdb24d4d1..0d33934b1e08 100644 --- a/common/lib/xmodule/xmodule/tests/test_import.py +++ b/common/lib/xmodule/xmodule/tests/test_import.py @@ -553,11 +553,7 @@ def test_unicode(self): # Expect to find an error/exception about characters in "®esources" expect = "InvalidKeyError" - errors = [ - (msg, err) - for msg, err # lint-amnesty, pylint: disable=unnecessary-comprehension - in modulestore.get_course_errors(course.id) - ] + errors = modulestore.get_course_errors(course.id) assert any(((expect in msg) or (expect in err)) for (msg, err) in errors) chapters = course.get_children() diff --git a/common/lib/xmodule/xmodule/video_module/video_handlers.py b/common/lib/xmodule/xmodule/video_module/video_handlers.py index 30660785ae38..8dba9d46381f 100644 --- a/common/lib/xmodule/xmodule/video_module/video_handlers.py +++ b/common/lib/xmodule/xmodule/video_module/video_handlers.py @@ -58,6 +58,8 @@ class VideoStudentViewHandlers: """ Handlers for video module instance. """ + global_speed = None + transcript_language = None def handle_ajax(self, dispatch, data): """ @@ -97,7 +99,7 @@ def handle_ajax(self, dispatch, data): setattr(self, key, value) if key == 'speed': - self.global_speed = self.speed # lint-amnesty, pylint: disable=attribute-defined-outside-init + self.global_speed = self.speed return json.dumps({'success': True}) @@ -238,14 +240,14 @@ def publish_completion(self, data, dispatch): # pylint: disable=unused-argument Return value: JSON response (200 on success, 400 for malformed data) """ completion_service = self.runtime.service(self, 'completion') - if completion_service is None: # lint-amnesty, pylint: disable=no-else-raise + if completion_service is None: raise JsonHandlerError(500, "No completion service found") - elif not completion_service.completion_tracking_enabled(): + if not completion_service.completion_tracking_enabled(): raise JsonHandlerError(404, "Completion tracking is not enabled and API calls are unexpected") - if not isinstance(data['completion'], (int, float)): # lint-amnesty, pylint: disable=no-else-raise + if not isinstance(data['completion'], (int, float)): message = "Invalid completion value {}. Must be a float in range [0.0, 1.0]" raise JsonHandlerError(400, message.format(data['completion'])) - elif not 0.0 <= data['completion'] <= 1.0: + if not 0.0 <= data['completion'] <= 1.0: message = "Invalid completion value {}. Must be in range [0.0, 1.0]" raise JsonHandlerError(400, message.format(data['completion'])) self.runtime.publish(self, "completion", data) @@ -321,8 +323,8 @@ def transcript(self, request, dispatch): log.info("Video: transcript facilities are not available for given language.") return Response(status=404) - if language != self.transcript_language: # lint-amnesty, pylint: disable=access-member-before-definition - self.transcript_language = language # lint-amnesty, pylint: disable=attribute-defined-outside-init + if language != self.transcript_language: + self.transcript_language = language try: if is_bumper: @@ -446,9 +448,9 @@ def validate_transcript_upload_data(self, data): elif ( data['language_code'] != data['new_language_code'] and data['new_language_code'] in available_translations ): - error = _('A transcript with the "{language_code}" language code already exists.'.format( # lint-amnesty, pylint: disable=translation-of-non-string - language_code=data['new_language_code'] - )) + error = _('A transcript with the "{language_code}" language code already exists.').format( + language_code=data['new_language_code'], + ) elif 'file' not in data: error = _('A transcript file is required.') diff --git a/common/test/acceptance/fixtures/base.py b/common/test/acceptance/fixtures/base.py index fefade736594..b0aed9b7e84c 100644 --- a/common/test/acceptance/fixtures/base.py +++ b/common/test/acceptance/fixtures/base.py @@ -56,7 +56,7 @@ def session_cookies(self): Log in as a staff user, then return the cookies for the session (as a dict) Raises a `StudioApiLoginError` if the login fails. """ - return {key: val for key, val in self.session.cookies.items()} # lint-amnesty, pylint: disable=unnecessary-comprehension + return dict(self.session.cookies.items()) @lazy def headers(self): diff --git a/common/test/acceptance/fixtures/config.py b/common/test/acceptance/fixtures/config.py index 29596d6dd464..d4346d841f07 100644 --- a/common/test/acceptance/fixtures/config.py +++ b/common/test/acceptance/fixtures/config.py @@ -61,7 +61,7 @@ def session_cookies(self): Log in as a staff user, then return the cookies for the session (as a dict) Raises a `ConfigModelFixtureError` if the login fails. """ - return {key: val for key, val in self.session.cookies.items()} # lint-amnesty, pylint: disable=unnecessary-comprehension + return dict(self.session.cookies.items()) @lazy def headers(self): diff --git a/lms/djangoapps/ccx/tests/test_field_override_performance.py b/lms/djangoapps/ccx/tests/test_field_override_performance.py index 8cfca804d33a..fe207214103b 100644 --- a/lms/djangoapps/ccx/tests/test_field_override_performance.py +++ b/lms/djangoapps/ccx/tests/test_field_override_performance.py @@ -55,7 +55,7 @@ class FieldOverridePerformanceTestCase(FieldOverrideTestMixin, ProceduralCourseT """ __test__ = False # Tell Django to clean out all databases, not just default - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) # TEST_DATA must be overridden by subclasses TEST_DATA = None diff --git a/lms/djangoapps/course_goals/api.py b/lms/djangoapps/course_goals/api.py index 0415ae568591..069b82eb6533 100644 --- a/lms/djangoapps/course_goals/api.py +++ b/lms/djangoapps/course_goals/api.py @@ -86,7 +86,7 @@ def get_course_goal_options(): Returns the valid options for goal keys, mapped to their translated strings, as defined by theCourseGoal model. """ - return {goal_key: goal_text for goal_key, goal_text in GOAL_KEY_CHOICES} # lint-amnesty, pylint: disable=unnecessary-comprehension + return dict(GOAL_KEY_CHOICES) def get_course_goal_text(goal_key): diff --git a/lms/djangoapps/course_wiki/plugins/markdownedx/mdx_mathjax.py b/lms/djangoapps/course_wiki/plugins/markdownedx/mdx_mathjax.py index f9bdc876085e..d2eb48924855 100644 --- a/lms/djangoapps/course_wiki/plugins/markdownedx/mdx_mathjax.py +++ b/lms/djangoapps/course_wiki/plugins/markdownedx/mdx_mathjax.py @@ -1,14 +1,12 @@ -# Source: https://github.com/mayoff/python-markdown-mathjax # lint-amnesty, pylint: disable=missing-module-docstring +""" +Add MathJax Markdown support +Source: https://github.com/mayoff/python-markdown-mathjax +""" +from xml.etree import ElementTree import markdown - -try: - # Markdown 2.1.0 changed from 2.0.3. We try importing the new version first, - # but import the 2.0.3 version if it fails - from markdown.util import etree, AtomicString -except: # lint-amnesty, pylint: disable=bare-except - from markdown import etree, AtomicString +from markdown.util import AtomicString class MathJaxPattern(markdown.inlinepatterns.Pattern): # lint-amnesty, pylint: disable=missing-class-docstring @@ -17,7 +15,7 @@ def __init__(self): markdown.inlinepatterns.Pattern.__init__(self, r'(?>> markdown.markdown(s, ['video']) u'

' """ - +from xml.etree import ElementTree import markdown -try: - # Markdown 2.1.0 changed from 2.0.3. We try importing the new version first, - # but import the 2.0.3 version if it fails - from markdown.util import etree -except ImportError: - from markdown import etree - version = "0.1.6" @@ -254,7 +247,7 @@ def handleMatch(self, m): width = self.ext.config['yahoo_width'][0] height = self.ext.config['yahoo_height'][0] obj = flash_object(url, width, height) - param = etree.Element('param') + param = ElementTree.Element('param') param.set('name', 'flashVars') param.set('value', "id={}&vid={}".format(m.group('yahooid'), m.group('yahoovid'))) obj.append(param) @@ -271,16 +264,16 @@ def handleMatch(self, m): def flash_object(url, width, height): # lint-amnesty, pylint: disable=missing-function-docstring - obj = etree.Element('object') + obj = ElementTree.Element('object') obj.set('type', 'application/x-shockwave-flash') obj.set('width', width) obj.set('height', height) obj.set('data', url) - param = etree.Element('param') + param = ElementTree.Element('param') param.set('name', 'movie') param.set('value', url) obj.append(param) - param = etree.Element('param') + param = ElementTree.Element('param') param.set('name', 'allowFullScreen') param.set('value', 'true') obj.append(param) diff --git a/lms/djangoapps/courseware/tests/test_model_data.py b/lms/djangoapps/courseware/tests/test_model_data.py index dffd52bbdf31..acd639a2e019 100644 --- a/lms/djangoapps/courseware/tests/test_model_data.py +++ b/lms/djangoapps/courseware/tests/test_model_data.py @@ -111,7 +111,7 @@ class TestStudentModuleStorage(OtherUserFailureTestMixin, TestCase): other_key_factory = partial(DjangoKeyValueStore.Key, Scope.user_state, 2, LOCATION('usage_id')) # user_id=2, not 1 existing_field_name = "a_field" # Tell Django to clean out all databases, not just default - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) def setUp(self): super().setUp() @@ -241,7 +241,7 @@ def test_set_many_failure(self): class TestMissingStudentModule(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring # Tell Django to clean out all databases, not just default - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) def setUp(self): super().setUp() diff --git a/lms/djangoapps/courseware/tests/test_submitting_problems.py b/lms/djangoapps/courseware/tests/test_submitting_problems.py index 7721f11ec523..ee48966ae4f2 100644 --- a/lms/djangoapps/courseware/tests/test_submitting_problems.py +++ b/lms/djangoapps/courseware/tests/test_submitting_problems.py @@ -137,7 +137,7 @@ class TestSubmittingProblems(ModuleStoreTestCase, LoginEnrollmentTestCase, Probl """ # Tell Django to clean out all databases, not just default - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) # arbitrary constant COURSE_SLUG = "100" COURSE_NAME = "test_course" @@ -339,7 +339,7 @@ class TestCourseGrader(TestSubmittingProblems): Suite of tests for the course grader. """ # Tell Django to clean out all databases, not just default - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) def basic_setup(self, late=False, reset=False, showanswer=False): """ @@ -752,7 +752,7 @@ def test_min_grade_credit_requirements_status(self, mode): class ProblemWithUploadedFilesTest(TestSubmittingProblems): """Tests of problems with uploaded files.""" # Tell Django to clean out all databases, not just default - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) def setUp(self): super().setUp() @@ -808,7 +808,7 @@ class TestPythonGradedResponse(TestSubmittingProblems): Check that we can submit a schematic and custom response, and it answers properly. """ # Tell Django to clean out all databases, not just default - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) SCHEMATIC_SCRIPT = dedent(""" # for a schematic response, submission[i] is the json representation diff --git a/lms/djangoapps/courseware/tests/test_user_state_client.py b/lms/djangoapps/courseware/tests/test_user_state_client.py index 1a78d52b21d1..c1e35b1da2ee 100644 --- a/lms/djangoapps/courseware/tests/test_user_state_client.py +++ b/lms/djangoapps/courseware/tests/test_user_state_client.py @@ -22,7 +22,7 @@ class TestDjangoUserStateClient(UserStateClientTestBase, ModuleStoreTestCase): """ __test__ = True # Tell Django to clean out all databases, not just default - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) def _user(self, user_idx): # lint-amnesty, pylint: disable=arguments-differ return self.users[user_idx].username diff --git a/lms/djangoapps/coursewarehistoryextended/tests.py b/lms/djangoapps/coursewarehistoryextended/tests.py index 64fe61a777d2..a97adb96f485 100644 --- a/lms/djangoapps/coursewarehistoryextended/tests.py +++ b/lms/djangoapps/coursewarehistoryextended/tests.py @@ -24,7 +24,7 @@ class TestStudentModuleHistoryBackends(TestCase): """ Tests of data in CSMH and CSMHE """ # Tell Django to clean out all databases, not just default - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) def setUp(self): super().setUp() diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index e431e6b39cfa..fcd50d54d4b0 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -328,7 +328,7 @@ def register_and_enroll_students(request, course_id): # pylint: disable=too-man try: upload_file = request.FILES.get('students_list') if upload_file.name.endswith('.csv'): - students = [row for row in csv.reader(upload_file.read().decode('utf-8').splitlines())] # lint-amnesty, pylint: disable=unnecessary-comprehension + students = list(csv.reader(upload_file.read().decode('utf-8').splitlines())) course = get_course_by_id(course_id) else: general_errors.append({ @@ -3185,7 +3185,7 @@ def build_row_errors(key, _user, row_count): try: upload_file = request.FILES.get('students_list') if upload_file.name.endswith('.csv'): - students = [row for row in csv.reader(upload_file.read().decode('utf-8').splitlines())] # lint-amnesty, pylint: disable=unnecessary-comprehension + students = list(csv.reader(upload_file.read().decode('utf-8').splitlines())) else: general_errors.append(_('Make sure that the file you upload is in CSV format with no ' 'extraneous characters or rows.')) diff --git a/lms/djangoapps/instructor_analytics/distributions.py b/lms/djangoapps/instructor_analytics/distributions.py index b591983a9bbb..1a91771a2fa2 100644 --- a/lms/djangoapps/instructor_analytics/distributions.py +++ b/lms/djangoapps/instructor_analytics/distributions.py @@ -111,8 +111,7 @@ def profile_distribution(course_id, feature): raw_choices = UserProfile.LEVEL_OF_EDUCATION_CHOICES # short name and display name (full) of the choices. - choices = [(short, full) - for (short, full) in raw_choices] + [('no_data', 'No Data')] # lint-amnesty, pylint: disable=unnecessary-comprehension + choices = list(raw_choices) + [('no_data', 'No Data')] def get_filter(feature, value): """ Get the orm filter parameters for a feature. """ diff --git a/lms/djangoapps/instructor_task/tests/test_base.py b/lms/djangoapps/instructor_task/tests/test_base.py index 13961f9264fb..d34bc63d09fa 100644 --- a/lms/djangoapps/instructor_task/tests/test_base.py +++ b/lms/djangoapps/instructor_task/tests/test_base.py @@ -354,7 +354,7 @@ def verify_rows_in_csv(self, expected_rows, file_index=0, verify_order=True, ign report_path = report_store.path_to(self.course.id, report_csv_filename) with report_store.storage.open(report_path) as csv_file: # Expand the dict reader generator so we don't lose it's content - csv_rows = [row for row in unicodecsv.DictReader(csv_file, encoding='utf-8-sig')] # lint-amnesty, pylint: disable=unnecessary-comprehension + csv_rows = list(unicodecsv.DictReader(csv_file, encoding='utf-8-sig')) if ignore_other_columns: csv_rows = [ diff --git a/lms/djangoapps/instructor_task/views.py b/lms/djangoapps/instructor_task/views.py index ada463600ca3..e9f678b41f69 100644 --- a/lms/djangoapps/instructor_task/views.py +++ b/lms/djangoapps/instructor_task/views.py @@ -13,7 +13,7 @@ log = logging.getLogger(__name__) # return status for completed tasks and tasks in progress -STATES_WITH_STATUS = [state for state in READY_STATES] + [PROGRESS] # lint-amnesty, pylint: disable=unnecessary-comprehension +STATES_WITH_STATUS = list(READY_STATES) + [PROGRESS] def _get_instructor_task_status(task_id): diff --git a/lms/djangoapps/support/views/program_enrollments.py b/lms/djangoapps/support/views/program_enrollments.py index fa42fa32bece..077b941e90fa 100644 --- a/lms/djangoapps/support/views/program_enrollments.py +++ b/lms/djangoapps/support/views/program_enrollments.py @@ -111,7 +111,7 @@ def _validate_and_link(program_uuid_string, linkage_text): for item in ext_key_to_username.items() if item not in link_errors ] - errors = [message for message in link_errors.values()] # lint-amnesty, pylint: disable=unnecessary-comprehension + errors = list(link_errors.values()) return successes, errors diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index 54918e0f3db7..4df21b4ca607 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -177,7 +177,10 @@ def should_show_debug_toolbar(request): # lint-amnesty, pylint: disable=missing ########################## Course Discovery ####################### -LANGUAGE_MAP = {'terms': {lang: display for lang, display in ALL_LANGUAGES}, 'name': 'Language'} # lint-amnesty, pylint: disable=unnecessary-comprehension +LANGUAGE_MAP = { + 'terms': dict(ALL_LANGUAGES), + 'name': 'Language', +} COURSE_DISCOVERY_MEANINGS = { 'org': { 'name': 'Organization', diff --git a/openedx/core/djangoapps/content/block_structure/tests/helpers.py b/openedx/core/djangoapps/content/block_structure/tests/helpers.py index 5e7add7b07a5..93655c79e16e 100644 --- a/openedx/core/djangoapps/content/block_structure/tests/helpers.py +++ b/openedx/core/djangoapps/content/block_structure/tests/helpers.py @@ -223,7 +223,7 @@ def mock_registered_transformers(transformers): 'openedx.core.djangoapps.content.block_structure.transformer_registry.' 'TransformerRegistry.get_registered_transformers' ) as mock_available_transforms: - mock_available_transforms.return_value = {transformer for transformer in transformers} # lint-amnesty, pylint: disable=unnecessary-comprehension + mock_available_transforms.return_value = set(transformers) yield diff --git a/openedx/core/djangoapps/content_libraries/tests/test_runtime.py b/openedx/core/djangoapps/content_libraries/tests/test_runtime.py index fa6352d8559d..d9c550252297 100644 --- a/openedx/core/djangoapps/content_libraries/tests/test_runtime.py +++ b/openedx/core/djangoapps/content_libraries/tests/test_runtime.py @@ -191,7 +191,7 @@ class ContentLibraryXBlockUserStateTest(ContentLibraryContentTestMixin, TestCase if the library allows direct learning. """ - databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension + databases = set(connections) @XBlock.register_temp_plugin(UserStateTestBlock, UserStateTestBlock.BLOCK_TYPE) def test_default_values(self): diff --git a/openedx/core/djangoapps/user_api/accounts/serializers.py b/openedx/core/djangoapps/user_api/accounts/serializers.py index c6198ef51ce3..1e8e11342b19 100644 --- a/openedx/core/djangoapps/user_api/accounts/serializers.py +++ b/openedx/core/djangoapps/user_api/accounts/serializers.py @@ -296,7 +296,7 @@ def validate_language_proficiencies(self, value): """ Enforce all languages are unique. """ - language_proficiencies = [language for language in value] # lint-amnesty, pylint: disable=unnecessary-comprehension + language_proficiencies = list(value) unique_language_proficiencies = {language["code"] for language in language_proficiencies} if len(language_proficiencies) != len(unique_language_proficiencies): raise serializers.ValidationError("The language_proficiencies field must consist of unique languages.") @@ -306,7 +306,7 @@ def validate_social_links(self, value): """ Enforce only one entry for a particular social platform. """ - social_links = [social_link for social_link in value] # lint-amnesty, pylint: disable=unnecessary-comprehension + social_links = list(value) unique_social_links = {social_link["platform"] for social_link in social_links} if len(social_links) != len(unique_social_links): raise serializers.ValidationError("The social_links field must consist of unique social platforms.") diff --git a/openedx/core/djangoapps/user_api/accounts/tests/retirement_helpers.py b/openedx/core/djangoapps/user_api/accounts/tests/retirement_helpers.py index 1828c63e1fd9..a3c40002f61c 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/retirement_helpers.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/retirement_helpers.py @@ -152,10 +152,10 @@ def _create_users_all_states(self): return [create_retirement_status(UserFactory(), state=state) for state in RetirementState.objects.all()] def _get_non_dead_end_states(self): - return [state for state in RetirementState.objects.filter(is_dead_end_state=False)] # lint-amnesty, pylint: disable=unnecessary-comprehension + return RetirementState.objects.filter(is_dead_end_state=False) def _get_dead_end_states(self): - return [state for state in RetirementState.objects.filter(is_dead_end_state=True)] # lint-amnesty, pylint: disable=unnecessary-comprehension + return RetirementState.objects.filter(is_dead_end_state=True) def fake_requested_retirement(user): diff --git a/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py b/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py index 0a1a5121ae58..303976df0896 100644 --- a/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py +++ b/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py @@ -401,7 +401,7 @@ def _run_command(self, org, other_names=None, only_courses=None, query_interval= try: with open(output_path) as output_file: reader = csv.DictReader(output_file, fieldnames=self.OUTPUT_FIELD_NAMES) - rows = [row for row in reader] # lint-amnesty, pylint: disable=unnecessary-comprehension + rows = list(reader) except OSError: self.fail(f"Could not find or open output file at '{output_path}'") diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_register.py b/openedx/core/djangoapps/user_authn/views/tests/test_register.py index 869a270c399e..66a277c6e335 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_register.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_register.py @@ -2278,11 +2278,11 @@ def test_no_decision_for_invalid_request(self): ) @ddt.data( - ['name', [name for name in testutils.VALID_NAMES]], # lint-amnesty, pylint: disable=unnecessary-comprehension - ['email', [email for email in testutils.VALID_EMAILS]], # lint-amnesty, pylint: disable=unnecessary-comprehension, line-too-long - ['password', [password for password in testutils.VALID_PASSWORDS]], # lint-amnesty, pylint: disable=unnecessary-comprehension, line-too-long - ['username', [username for username in testutils.VALID_USERNAMES]], # lint-amnesty, pylint: disable=unnecessary-comprehension, line-too-long - ['country', [country for country in testutils.VALID_COUNTRIES]] # lint-amnesty, pylint: disable=unnecessary-comprehension, line-too-long + ['name', list(testutils.VALID_NAMES)], + ['email', list(testutils.VALID_EMAILS)], + ['password', list(testutils.VALID_PASSWORDS)], + ['username', list(testutils.VALID_USERNAMES)], + ['country', list(testutils.VALID_COUNTRIES)], ) @ddt.unpack def test_positive_validation_decision(self, form_field_name, user_data): @@ -2296,11 +2296,11 @@ def test_positive_validation_decision(self, form_field_name, user_data): @ddt.data( # Skip None type for invalidity checks. - ['name', [name for name in testutils.INVALID_NAMES[1:]]], # lint-amnesty, pylint: disable=unnecessary-comprehension, line-too-long - ['email', [email for email in testutils.INVALID_EMAILS[1:]]], # lint-amnesty, pylint: disable=unnecessary-comprehension, line-too-long - ['password', [password for password in testutils.INVALID_PASSWORDS[1:]]], # lint-amnesty, pylint: disable=unnecessary-comprehension, line-too-long - ['username', [username for username in testutils.INVALID_USERNAMES[1:]]], # lint-amnesty, pylint: disable=unnecessary-comprehension, line-too-long - ['country', [country for country in testutils.INVALID_COUNTRIES[1:]]] # lint-amnesty, pylint: disable=unnecessary-comprehension, line-too-long + ['name', testutils.INVALID_NAMES[1:]], + ['email', testutils.INVALID_EMAILS[1:]], + ['password', testutils.INVALID_PASSWORDS[1:]], + ['username', testutils.INVALID_USERNAMES[1:]], + ['country', testutils.INVALID_COUNTRIES[1:]], ) @ddt.unpack def test_negative_validation_decision(self, form_field_name, user_data): diff --git a/openedx/core/lib/api/view_utils.py b/openedx/core/lib/api/view_utils.py index 24ddc838874e..3030b9f00533 100644 --- a/openedx/core/lib/api/view_utils.py +++ b/openedx/core/lib/api/view_utils.py @@ -2,7 +2,7 @@ Utilities related to API views """ -from collections import Sequence # lint-amnesty, pylint: disable=no-name-in-module, deprecated-class +from collections.abc import Sequence from functools import wraps from django.core.exceptions import NON_FIELD_ERRORS, ObjectDoesNotExist, ValidationError