From 9b9b88df5203b83d438d83f13481b5471ca2b559 Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Mon, 17 Jul 2023 12:18:43 -0700 Subject: [PATCH] chore: remove some usages of six (Python2 compat) (#32554) * get rid of six.text_type(s) * get rid of six.b() * get rid of six.string_types * get rid of six.PY2/six.PY3 * get rid of six.iteritems() and six.viewvalues() --- cms/djangoapps/contentstore/tasks.py | 4 +- cms/templates/certificates.html | 3 +- cms/templates/checklists.html | 4 +- cms/templates/course_outline.html | 5 +-- cms/templates/export_git.html | 4 +- cms/templates/group_configurations.html | 3 +- cms/templates/manage_users.html | 4 +- cms/templates/settings.html | 3 +- cms/templates/settings_advanced.html | 5 +-- cms/templates/settings_graders.html | 3 +- cms/templates/widgets/header.html | 43 +++++++++---------- cms/templates/widgets/metadata-edit.html | 3 +- cms/templates/widgets/source-edit.html | 3 +- common/djangoapps/edxmako/paths.py | 5 +-- .../tests/test_bulk_change_enrollment_csv.py | 3 +- .../management/tests/test_bulk_unenroll.py | 3 +- .../management/tests/test_recover_account.py | 3 +- .../tests/test_unsubscribe_user_email.py | 3 +- common/djangoapps/student/tests/test_roles.py | 13 +++--- common/djangoapps/terrain/stubs/http.py | 2 +- common/djangoapps/track/contexts.py | 1 - lms/djangoapps/ccx/views.py | 6 +-- .../discussion/notification_prefs/views.py | 3 +- lms/djangoapps/grades/api.py | 1 - .../teams/templates/teams/teams.html | 4 +- lms/djangoapps/teams/tests/test_models.py | 2 +- lms/templates/conditional_block.html | 5 +-- lms/templates/course.html | 3 +- lms/templates/courseware/course_about.html | 9 ++-- .../course_about_sidebar_header.html | 3 +- lms/templates/courseware/courseware.html | 5 +-- lms/templates/courseware/gradebook.html | 3 +- lms/templates/courseware/xqa_interface.html | 5 +-- lms/templates/dashboard.html | 3 +- .../dashboard/_dashboard_course_listing.html | 7 ++- .../_dashboard_entitlement_actions.html | 5 +-- .../header/navbar-not-authenticated.html | 1 - lms/templates/main.html | 3 +- .../navigation/navbar-not-authenticated.html | 1 - lms/templates/public_video_share_embed.html | 3 +- lms/templates/staff_problem_info.html | 3 +- lms/templates/support/index.html | 3 +- lms/templates/survey/survey.html | 3 +- openedx/core/djangoapps/credit/signature.py | 2 +- .../lms/templates/register-form.html | 3 +- xmodule/capa/capa_problem.py | 11 +++-- xmodule/capa/inputtypes.py | 21 +++------ xmodule/capa/responsetypes.py | 31 +++++++------ xmodule/capa/safe_exec/safe_exec.py | 10 ++--- .../capa/safe_exec/tests/test_safe_exec.py | 13 +++--- xmodule/capa/templates/choicegroup.html | 5 +-- xmodule/capa/tests/helpers.py | 6 +-- xmodule/capa/tests/response_xml_factory.py | 2 +- xmodule/capa/tests/test_capa_problem.py | 8 ++-- xmodule/capa/tests/test_inputtypes.py | 1 - xmodule/capa/tests/test_responsetypes.py | 10 ++--- xmodule/capa/util.py | 3 +- xmodule/modulestore/mongo/base.py | 2 +- 58 files changed, 124 insertions(+), 205 deletions(-) diff --git a/cms/djangoapps/contentstore/tasks.py b/cms/djangoapps/contentstore/tasks.py index d452b2f004..4d4fff967c 100644 --- a/cms/djangoapps/contentstore/tasks.py +++ b/cms/djangoapps/contentstore/tasks.py @@ -296,7 +296,7 @@ class CourseExportTask(UserTask): # pylint: disable=abstract-method arguments_dict (dict): The arguments given to the task function Returns: - text_type: The generated name + str: The generated name """ key = arguments_dict['course_key_string'] return f'Export of {key}' @@ -431,7 +431,7 @@ class CourseImportTask(UserTask): # pylint: disable=abstract-method arguments_dict (dict): The arguments given to the task function Returns: - text_type: The generated name + str: The generated name """ key = arguments_dict['course_key_string'] filename = arguments_dict['archive_name'] diff --git a/cms/templates/certificates.html b/cms/templates/certificates.html index edf4e45c6c..400d300bf5 100644 --- a/cms/templates/certificates.html +++ b/cms/templates/certificates.html @@ -9,7 +9,6 @@ from openedx.core.djangolib.markup import HTML, Text from openedx.core.djangolib.js_utils import ( dump_js_escaped_json, js_escaped_string ) -import six from six.moves.urllib.parse import quote %> @@ -104,7 +103,7 @@ CMS.User.isGlobalStaff = '${is_global_staff | n, js_escaped_string}'=='True' ? t
% if context_course: <% - url_encoded_course_id = quote(six.text_type(context_course.id).encode('utf-8'), safe='') + url_encoded_course_id = quote(str(context_course.id).encode('utf-8'), safe='') details_url = utils.reverse_course_url('settings_handler', context_course.id) grading_url = utils.reverse_course_url('grading_handler', context_course.id) course_team_url = utils.reverse_course_url('course_team_handler', context_course.id) diff --git a/cms/templates/checklists.html b/cms/templates/checklists.html index 44d456de26..e949f37d79 100644 --- a/cms/templates/checklists.html +++ b/cms/templates/checklists.html @@ -2,8 +2,6 @@ <%inherit file="base.html" /> <%def name="online_help_token()"><% return "files" %> <%! - import six - from cms.djangoapps.contentstore import utils from cms.djangoapps.contentstore.config.waffle_utils import should_show_checklists_quality from django.urls import reverse @@ -40,7 +38,7 @@ <%static:studiofrontend entry="courseHealthCheck"> <% - course_key = six.text_type(context_course.id) + course_key = str(context_course.id) certificates_url = '' if has_certificates_enabled(context_course): certificates_url = utils.reverse_course_url('certificates_list_handler', course_key) diff --git a/cms/templates/course_outline.html b/cms/templates/course_outline.html index fd68ad9cd4..915ec64da4 100644 --- a/cms/templates/course_outline.html +++ b/cms/templates/course_outline.html @@ -3,7 +3,6 @@ <%def name="online_help_token()"><% return "develop_course" %> <%! import logging -import six from six.moves.urllib.parse import quote from cms.djangoapps.contentstore.config.waffle_utils import should_show_checklists_quality @@ -160,7 +159,7 @@ from django.urls import reverse

${_("This course has proctored exam settings that are incomplete or invalid.")}

% if mfe_proctored_exam_settings_url: - <% url_encoded_course_id = quote(six.text_type(context_course.id).encode('utf-8'), safe='') %> + <% url_encoded_course_id = quote(str(context_course.id).encode('utf-8'), safe='') %> ${Text(_("To update these settings go to the {link_start}Proctored Exam Settings page{link_end}.")).format( link_start=HTML('').format( mfe_proctored_exam_settings_url=mfe_proctored_exam_settings_url @@ -263,7 +262,7 @@ from django.urls import reverse }, "enable_quality": ${should_show_checklists_quality(context_course.id) | n, dump_js_escaped_json}, "links": { - "settings": ${reverse('settings_handler', kwargs={'course_key_string': six.text_type(course_key)})| n, dump_js_escaped_json} + "settings": ${reverse('settings_handler', kwargs={'course_key_string': str(course_key)})| n, dump_js_escaped_json} } } diff --git a/cms/templates/export_git.html b/cms/templates/export_git.html index fe6bd9dd16..296e3caa3a 100644 --- a/cms/templates/export_git.html +++ b/cms/templates/export_git.html @@ -3,8 +3,6 @@ <%namespace name='static' file='static_content.html'/> <%! - import six - from django.urls import reverse from django.utils.translation import gettext as _ %> @@ -41,7 +39,7 @@ % else: