diff --git a/common/lib/symmath/symmath/formula.py b/common/lib/symmath/symmath/formula.py index 56996b78eb..199b5aea1d 100644 --- a/common/lib/symmath/symmath/formula.py +++ b/common/lib/symmath/symmath/formula.py @@ -369,7 +369,7 @@ class formula(object): if ( tag == 'msup' and len(k) == 2 and gettag(k[1]) == 'mrow' and - gettag(k[1][0]) == 'mo' and k[1][0].text == u'\u200b' # whew + gettag(k[1][0]) == 'mo' and k[1][0].text == '\u200b' # whew ): # replace the msup with 'X__Y' @@ -384,7 +384,7 @@ class formula(object): if ( tag == 'msubsup' and len(k) == 3 and gettag(k[2]) == 'mrow' and - gettag(k[2][0]) == 'mo' and k[2][0].text == u'\u200b' # whew + gettag(k[2][0]) == 'mo' and k[2][0].text == '\u200b' # whew ): # replace the msubsup with 'X_Y__Z' diff --git a/common/test/acceptance/fixtures/course.py b/common/test/acceptance/fixtures/course.py index bf469e8c50..ff7045f386 100644 --- a/common/test/acceptance/fixtures/course.py +++ b/common/test/acceptance/fixtures/course.py @@ -354,7 +354,7 @@ class CourseFixture(XBlockContainerFixture): 'children': None, 'data': handouts_html, 'id': self._handouts_loc, - 'metadata': dict(), + 'metadata': {}, }) response = self.session.post(url, data=payload, headers=self.headers) diff --git a/common/test/acceptance/pages/studio/video/video.py b/common/test/acceptance/pages/studio/video/video.py index 68f2f85068..ed7b2030c6 100644 --- a/common/test/acceptance/pages/studio/video/video.py +++ b/common/test/acceptance/pages/studio/video/video.py @@ -269,7 +269,7 @@ class VideoComponentPage(VideoPage): """ Download handout at `url` """ - kwargs = dict() + kwargs = {} session_id = [{i['name']: i['value']} for i in self.browser.get_cookies() if i['name'] == 'sessionid'] if session_id: kwargs.update({ diff --git a/lms/djangoapps/badges/backends/badgr.py b/lms/djangoapps/badges/backends/badgr.py index 09773b3823..7569c41a2a 100644 --- a/lms/djangoapps/badges/backends/badgr.py +++ b/lms/djangoapps/badges/backends/badgr.py @@ -302,7 +302,7 @@ class BadgrBackend(BadgeBackend): Headers to send along with the request-- used for authentication. """ access_token = self._get_access_token() - return {'Authorization': u'Bearer {}'.format(access_token)} + return {'Authorization': 'Bearer {}'.format(access_token)} def _ensure_badge_created(self, badge_class): """ diff --git a/lms/djangoapps/certificates/api.py b/lms/djangoapps/certificates/api.py index 8939e6e805..fac9823b22 100644 --- a/lms/djangoapps/certificates/api.py +++ b/lms/djangoapps/certificates/api.py @@ -585,7 +585,7 @@ def get_certificate_footer_context(): Return data to be used in Certificate Footer, data returned should be customized according to the site configuration. """ - data = dict() + data = {} # get Terms of Service and Honor Code page url terms_of_service_and_honor_code = branding_api.get_tos_and_honor_code_url() diff --git a/lms/djangoapps/course_api/forms.py b/lms/djangoapps/course_api/forms.py index 7111039bf6..94fb34fde6 100644 --- a/lms/djangoapps/course_api/forms.py +++ b/lms/djangoapps/course_api/forms.py @@ -71,7 +71,7 @@ class CourseListGetForm(UsernameValidatorMixin, Form): cleaned_data = super().clean() # create a filter for all supported filter fields - filter_ = dict() + filter_ = {} for supported_filter in self.supported_filters: if cleaned_data.get(supported_filter.param_name) is not None: filter_[supported_filter.field_name] = cleaned_data[supported_filter.param_name] diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index ac2de79d2e..bee106a483 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -173,7 +173,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, field_ if course_module is None: return None, None, None - toc_chapters = list() + toc_chapters = [] chapters = course_module.get_display_items() # Check for content which needs to be completed @@ -201,7 +201,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, field_ if chapter.hide_from_toc or local_hide_from_toc: continue - sections = list() + sections = [] for section in chapter.get_display_items(): # skip the section if it is hidden from the user if section.hide_from_toc: diff --git a/lms/djangoapps/courseware/tabs.py b/lms/djangoapps/courseware/tabs.py index fa27e3fd69..b851e625ad 100644 --- a/lms/djangoapps/courseware/tabs.py +++ b/lms/djangoapps/courseware/tabs.py @@ -311,7 +311,7 @@ class SingleTextbookTab(CourseTab): """ Constructs a link for textbooks from a view name, a course, and an index. """ return reverse_func(view_name, args=[str(course.id), index]) - tab_dict = dict() + tab_dict = {} tab_dict['name'] = name tab_dict['tab_id'] = tab_id tab_dict['link_func'] = link_func @@ -393,10 +393,10 @@ def _get_dynamic_tabs(course, user): Note: dynamic tabs are those that are not persisted in the course, but are instead added dynamically based upon the user's role. """ - dynamic_tabs = list() + dynamic_tabs = [] for tab_type in CourseTabPluginManager.get_tab_types(): if getattr(tab_type, "is_dynamic", False): - tab = tab_type(dict()) + tab = tab_type({}) if tab.is_enabled(course, user=user): dynamic_tabs.append(tab) dynamic_tabs.sort(key=lambda dynamic_tab: dynamic_tab.name) diff --git a/lms/djangoapps/courseware/tests/test_course_info.py b/lms/djangoapps/courseware/tests/test_course_info.py index 30b9cd6f9b..04977b62d9 100644 --- a/lms/djangoapps/courseware/tests/test_course_info.py +++ b/lms/djangoapps/courseware/tests/test_course_info.py @@ -238,7 +238,7 @@ class CourseInfoTitleTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase): @ddt.data( # Default site configuration shows course number, org, and display name as subtitle. - (dict(), + ({}, "Welcome to HogwartsX's Potions101!", "Introduction to Potions"), # Show org in title diff --git a/lms/djangoapps/edxnotes/helpers.py b/lms/djangoapps/edxnotes/helpers.py index ae9cf7d7f6..70b26d8041 100644 --- a/lms/djangoapps/edxnotes/helpers.py +++ b/lms/djangoapps/edxnotes/helpers.py @@ -162,7 +162,7 @@ def preprocess_collection(user, course, collection): # pylint: disable=too-many-statements store = modulestore() - filtered_collection = list() + filtered_collection = [] cache = {} include_path_info = ('course_structure' not in settings.NOTES_DISABLED_TABS) with store.bulk_operations(course.id): 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 b0bc83369e..b97c192cc1 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 @@ -1383,7 +1383,7 @@ class GradebookViewTest(GradebookViewTestBase): def test_filter_course_roles(self, excluded_course_roles): """ Test that excluded_course_roles=all filters out any user with a course role """ # Create test users, enroll them in the course, and give them roles. - role_user_usernames = dict() + role_user_usernames = {} course_roles_to_create = [ CourseInstructorRole, CourseStaffRole, diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index fc2647ce3b..78efa9f098 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -542,7 +542,7 @@ def create_and_enroll_user(email, username, name, country, password, course_id, :return: list of errors """ - errors = list() + errors = [] try: with transaction.atomic(): # Create a new user diff --git a/lms/djangoapps/instructor_task/tests/test_integration.py b/lms/djangoapps/instructor_task/tests/test_integration.py index f2035e3037..daf1a93ef9 100644 --- a/lms/djangoapps/instructor_task/tests/test_integration.py +++ b/lms/djangoapps/instructor_task/tests/test_integration.py @@ -219,7 +219,7 @@ class TestRescoringTask(TestIntegrationTask): ) @ddt.data( - RescoreTestData(edit=dict(), new_expected_scores=(2, 1, 1, 0), new_expected_max=2), + RescoreTestData(edit={}, new_expected_scores=(2, 1, 1, 0), new_expected_max=2), RescoreTestData(edit=dict(correct_answer=OPTION_2), new_expected_scores=(2, 1, 1, 2), new_expected_max=2), ) @ddt.unpack diff --git a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py index b152bd8106..7420dfa9d5 100644 --- a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py +++ b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py @@ -1778,7 +1778,7 @@ class TestGradeReport(TestReportMixin, InstructorTaskModuleTestCase): metadata={'graded': True, 'format': 'Homework', 'start': in_the_future}, display_name='Unreleased' ) - self.define_option_problem(u'Unreleased', parent=self.unreleased_section) + self.define_option_problem('Unreleased', parent=self.unreleased_section) @patch.dict(settings.FEATURES, {'DISABLE_START_DATES': False}) @ddt.data(True, False) diff --git a/lms/djangoapps/program_enrollments/api/reading.py b/lms/djangoapps/program_enrollments/api/reading.py index 47ee586201..39442ce6e0 100644 --- a/lms/djangoapps/program_enrollments/api/reading.py +++ b/lms/djangoapps/program_enrollments/api/reading.py @@ -407,7 +407,7 @@ def get_users_by_external_keys_and_org_key(external_user_keys, org_key): ProviderDoesNotExistsException """ saml_providers = get_saml_providers_by_org_key(org_key) - found_users_by_external_keys = dict() + found_users_by_external_keys = {} # if the same external id exists in multiple providers (for this organization) # it is expected both providers return the same user for saml_provider in saml_providers: diff --git a/lms/djangoapps/teams/csv.py b/lms/djangoapps/teams/csv.py index 8ba93a0d15..f794d92e22 100644 --- a/lms/djangoapps/teams/csv.py +++ b/lms/djangoapps/teams/csv.py @@ -72,7 +72,7 @@ def _lookup_team_membership_data(course): team_membership_data = [] for course_enrollment in course_enrollments: # This dict contains all the user's team memberships keyed by teamset - student_row = teamset_memberships_by_user.get(course_enrollment.user, dict()) + student_row = teamset_memberships_by_user.get(course_enrollment.user, {}) student_row['user'] = _get_displayed_user_identifier(course_enrollment) student_row['mode'] = course_enrollment.mode team_membership_data.append(student_row) @@ -131,11 +131,11 @@ def _group_teamset_memberships_by_user(course_team_memberships): per user represented in input } """ - teamset_memberships_by_user = dict() + teamset_memberships_by_user = {} for team_membership in course_team_memberships: user = team_membership.user if user not in teamset_memberships_by_user: - teamset_memberships_by_user[user] = dict() + teamset_memberships_by_user[user] = {} topic_id = team_membership.team.topic_id team_name = team_membership.team.name teamset_memberships_by_user[user][topic_id] = team_name diff --git a/lms/djangoapps/teams/views.py b/lms/djangoapps/teams/views.py index 5358d67ae1..b6ece3c3f0 100644 --- a/lms/djangoapps/teams/views.py +++ b/lms/djangoapps/teams/views.py @@ -808,7 +808,7 @@ class TeamsDetailView(ExpandableFieldViewMixin, RetrievePatchAPIView): """DELETE /api/team/v0/teams/{team_id}""" team = get_object_or_404(CourseTeam, team_id=team_id) self.check_object_permissions(request, team) - # Note: list() forces the queryset to be evualuated before delete() + # Note: [] forces the queryset to be evualuated before delete() memberships = list(CourseTeamMembership.get_memberships(team_ids=[team_id])) # Note: also deletes all team memberships associated with this team