diff --git a/lms/djangoapps/course_wiki/middleware.py b/lms/djangoapps/course_wiki/middleware.py index 4a04f3cd9d..8aefe623f5 100644 --- a/lms/djangoapps/course_wiki/middleware.py +++ b/lms/djangoapps/course_wiki/middleware.py @@ -34,7 +34,7 @@ class WikiAccessMiddleware(MiddlewareMixin): # See if we are able to view the course. If we are, redirect to it try: get_course_overview_with_access(request.user, 'load', course_id) - return redirect("/courses/{course_id}/wiki/{path}".format(course_id=str(course_id), path=wiki_path)) # lint-amnesty, pylint: disable=line-too-long + return redirect(f"/courses/{str(course_id)}/wiki/{wiki_path}") # lint-amnesty, pylint: disable=line-too-long except Http404: # Even though we came from the course, we can't see it. So don't worry about it. pass @@ -57,7 +57,7 @@ class WikiAccessMiddleware(MiddlewareMixin): if course_id: # This is a /courses/org/name/run/wiki request - course_path = "/courses/{}".format(str(course_id)) + course_path = f"/courses/{str(course_id)}" # HACK: django-wiki monkeypatches the reverse function to enable # urls to be rewritten reverse._transform_url = lambda url: course_path + url # pylint: disable=protected-access diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index a49d3f64c1..535293e1bb 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -769,7 +769,7 @@ def get_cms_course_link(course, page='course'): """ # This is fragile, but unfortunately the problem is that within the LMS we # can't use the reverse calls from the CMS - return "//{}/{}/{}".format(settings.CMS_BASE, page, str(course.id)) + return f"//{settings.CMS_BASE}/{page}/{str(course.id)}" def get_cms_block_link(block, page): diff --git a/lms/djangoapps/courseware/models.py b/lms/djangoapps/courseware/models.py index c959b79aa8..2a7e581e9f 100644 --- a/lms/djangoapps/courseware/models.py +++ b/lms/djangoapps/courseware/models.py @@ -384,7 +384,7 @@ class OfflineComputedGradeLog(models.Model): nstudents = models.IntegerField(default=0) def __str__(self): - return "[OCGLog] {}: {}".format(str(self.course_id), self.created) + return f"[OCGLog] {str(self.course_id)}: {self.created}" class StudentFieldOverride(TimeStampedModel): diff --git a/lms/djangoapps/courseware/tabs.py b/lms/djangoapps/courseware/tabs.py index 625a5df5dd..44c0559b63 100644 --- a/lms/djangoapps/courseware/tabs.py +++ b/lms/djangoapps/courseware/tabs.py @@ -117,7 +117,7 @@ class ProgressTab(EnrolledTab): return reverse_func(self.view_name, args=[str(course.id)]) tab_dict['link_func'] = link_func - super(ProgressTab, self).__init__(tab_dict) # pylint: disable=super-with-arguments + super().__init__(tab_dict) # pylint: disable=super-with-arguments @classmethod def is_enabled(cls, course, user=None): diff --git a/lms/djangoapps/courseware/tests/test_courses.py b/lms/djangoapps/courseware/tests/test_courses.py index e5647b59c1..199487db44 100644 --- a/lms/djangoapps/courseware/tests/test_courses.py +++ b/lms/djangoapps/courseware/tests/test_courses.py @@ -71,9 +71,9 @@ class CoursesTest(ModuleStoreTestCase): org='org', number='num', display_name='name' ) - cms_url = "//{}/course/{}".format(CMS_BASE_TEST, str(self.course.id)) + cms_url = f"//{CMS_BASE_TEST}/course/{str(self.course.id)}" assert cms_url == get_cms_course_link(self.course) - cms_url = "//{}/course/{}".format(CMS_BASE_TEST, str(self.course.location)) + cms_url = f"//{CMS_BASE_TEST}/course/{str(self.course.location)}" assert cms_url == get_cms_block_link(self.course, 'course') @ddt.data(GET_COURSE_WITH_ACCESS, GET_COURSE_OVERVIEW_WITH_ACCESS) diff --git a/lms/djangoapps/courseware/tests/test_discussion_xblock.py b/lms/djangoapps/courseware/tests/test_discussion_xblock.py index 12a4e43bb2..e48973570a 100644 --- a/lms/djangoapps/courseware/tests/test_discussion_xblock.py +++ b/lms/djangoapps/courseware/tests/test_discussion_xblock.py @@ -246,8 +246,8 @@ class TestTemplates(TestDiscussionXBlock): fragment = self.block.student_view() read_only = 'false' if permissions[0] else 'true' assert f'data-discussion-id="{self.discussion_id}"' in fragment.content - assert 'data-user-create-comment="{}"'.format(json.dumps(permissions[1])) in fragment.content - assert 'data-user-create-subcomment="{}"'.format(json.dumps(permissions[2])) in fragment.content + assert f'data-user-create-comment="{json.dumps(permissions[1])}"' in fragment.content + assert f'data-user-create-subcomment="{json.dumps(permissions[2])}"' in fragment.content assert f'data-read-only="{read_only}"' in fragment.content diff --git a/lms/djangoapps/courseware/tests/test_entrance_exam.py b/lms/djangoapps/courseware/tests/test_entrance_exam.py index 5cf95c56e5..a530c33d82 100644 --- a/lms/djangoapps/courseware/tests/test_entrance_exam.py +++ b/lms/djangoapps/courseware/tests/test_entrance_exam.py @@ -538,7 +538,7 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest Tests entrance exam xblock has `entrance_exam_passed` key in json response. """ request_factory = RequestFactoryNoCsrf() - data = {'input_{}_2_1'.format(str(self.problem_1.location.html_id())): 'choice_2'} + data = {f'input_{str(self.problem_1.location.html_id())}_2_1': 'choice_2'} request = request_factory.post( 'problem_check', data=data diff --git a/lms/djangoapps/courseware/tests/test_lti_integration.py b/lms/djangoapps/courseware/tests/test_lti_integration.py index 2f4886b278..e96386b062 100644 --- a/lms/djangoapps/courseware/tests/test_lti_integration.py +++ b/lms/djangoapps/courseware/tests/test_lti_integration.py @@ -42,7 +42,7 @@ class TestLTI(BaseTestXmodule): context_id = str(self.item_descriptor.course_id) user_id = str(self.item_descriptor.xmodule_runtime.anonymous_student_id) hostname = self.item_descriptor.xmodule_runtime.hostname - resource_link_id = str(urllib.parse.quote('{}-{}'.format(hostname, self.item_descriptor.location.html_id()))) + resource_link_id = str(urllib.parse.quote(f'{hostname}-{self.item_descriptor.location.html_id()}')) sourcedId = "{context}:{resource_link}:{user_id}".format( context=urllib.parse.quote(context_id), diff --git a/lms/djangoapps/courseware/tests/test_module_render.py b/lms/djangoapps/courseware/tests/test_module_render.py index 6a8d601221..8a7bf333c1 100644 --- a/lms/djangoapps/courseware/tests/test_module_render.py +++ b/lms/djangoapps/courseware/tests/test_module_render.py @@ -1592,7 +1592,7 @@ class TestHtmlModifiers(ModuleStoreTestCase): ) result_fragment = module.render(STUDENT_VIEW) - assert '/courses/{course_id}/bar/content'.format(course_id=str(self.course.id)) in result_fragment.content + assert f'/courses/{str(self.course.id)}/bar/content' in result_fragment.content class XBlockWithJsonInitData(XBlock): diff --git a/lms/djangoapps/courseware/tests/test_split_module.py b/lms/djangoapps/courseware/tests/test_split_module.py index 8a443c5349..adb72e1ecb 100644 --- a/lms/djangoapps/courseware/tests/test_split_module.py +++ b/lms/djangoapps/courseware/tests/test_split_module.py @@ -125,7 +125,7 @@ class SplitTestBase(SharedModuleStoreTestCase): unicode_content = resp.content.decode(resp.charset) # Assert we see the proper icon in the top display - assert '