diff --git a/zerver/data_import/slack.py b/zerver/data_import/slack.py index 03dfeb2c94..e22d2ca21d 100644 --- a/zerver/data_import/slack.py +++ b/zerver/data_import/slack.py @@ -1479,9 +1479,7 @@ def check_token_access(token: str) -> None: missing_scopes = required_scopes - has_scopes if missing_scopes: raise ValueError( - "Slack token is missing the following required scopes: {}".format( - sorted(missing_scopes) - ) + f"Slack token is missing the following required scopes: {sorted(missing_scopes)}" ) else: raise Exception("Unknown token type -- must start with xoxb- or xoxp-") diff --git a/zerver/lib/url_preview/preview.py b/zerver/lib/url_preview/preview.py index e281013cff..edae547d6b 100644 --- a/zerver/lib/url_preview/preview.py +++ b/zerver/lib/url_preview/preview.py @@ -27,8 +27,8 @@ link_regex = re.compile( # Use Chrome User-Agent, since some sites refuse to work on old browsers ZULIP_URL_PREVIEW_USER_AGENT = ( - "Mozilla/5.0 (compatible; ZulipURLPreview/{version}; +{external_host})" -).format(version=ZULIP_VERSION, external_host=settings.ROOT_DOMAIN_URI) + f"Mozilla/5.0 (compatible; ZulipURLPreview/{ZULIP_VERSION}; +{settings.ROOT_DOMAIN_URI})" +) # FIXME: This header and timeout are not used by pyoembed, when trying to autodiscover! HEADERS = {"User-Agent": ZULIP_URL_PREVIEW_USER_AGENT} diff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.py index 873d515fce..6194e94352 100644 --- a/zerver/tests/test_message_fetch.py +++ b/zerver/tests/test_message_fetch.py @@ -4359,9 +4359,7 @@ class MessageHasKeywordsTest(ZulipTestCase): dummy_urls = [f"http://zulip.testserver/user_uploads/{x}" for x in dummy_path_ids] self.subscribe(hamlet, "Denmark") - body = ("Files ...[zulip.txt]({}) {} {}").format( - dummy_urls[0], dummy_urls[1], dummy_urls[2] - ) + body = f"Files ...[zulip.txt]({dummy_urls[0]}) {dummy_urls[1]} {dummy_urls[2]}" msg_id = self.send_stream_message(hamlet, "Denmark", body, "test") msg = Message.objects.get(id=msg_id) diff --git a/zerver/tests/test_user_groups.py b/zerver/tests/test_user_groups.py index 443fa80806..b357df9239 100644 --- a/zerver/tests/test_user_groups.py +++ b/zerver/tests/test_user_groups.py @@ -1180,9 +1180,7 @@ class UserGroupAPITestCase(UserGroupTestCase): result = self.client_post(f"/json/user_groups/{support_group.id}/subgroups", info=params) self.assert_json_error( result, - ("User group {group_id} is not a subgroup of this group.").format( - group_id=leadership_group.id - ), + f"User group {leadership_group.id} is not a subgroup of this group.", ) self.assert_subgroup_membership(support_group, []) @@ -1193,9 +1191,7 @@ class UserGroupAPITestCase(UserGroupTestCase): result = self.client_post(f"/json/user_groups/{support_group.id}/subgroups", info=params) self.assert_json_error( result, - ("User group {group_id} is already a subgroup of this group.").format( - group_id=leadership_group.id - ), + f"User group {leadership_group.id} is already a subgroup of this group.", ) self.assert_subgroup_membership(support_group, [leadership_group]) diff --git a/zerver/views/development/integrations.py b/zerver/views/development/integrations.py index 8c69aa61e5..9a9cadd7df 100644 --- a/zerver/views/development/integrations.py +++ b/zerver/views/development/integrations.py @@ -76,9 +76,7 @@ def get_fixtures(request: HttpRequest, integration_name: str = REQ()) -> HttpRes fixtures = {} fixtures_dir = os.path.join(ZULIP_PATH, f"zerver/webhooks/{valid_integration_name}/fixtures") if not os.path.exists(fixtures_dir): - msg = ('The integration "{valid_integration_name}" does not have fixtures.').format( - valid_integration_name=valid_integration_name - ) + msg = f'The integration "{valid_integration_name}" does not have fixtures.' raise ResourceNotFoundError(msg) for fixture in os.listdir(fixtures_dir): @@ -135,9 +133,7 @@ def send_all_webhook_fixture_messages( fixtures_dir = os.path.join(ZULIP_PATH, f"zerver/webhooks/{valid_integration_name}/fixtures") if not os.path.exists(fixtures_dir): - msg = ('The integration "{valid_integration_name}" does not have fixtures.').format( - valid_integration_name=valid_integration_name - ) + msg = f'The integration "{valid_integration_name}" does not have fixtures.' raise ResourceNotFoundError(msg) responses = [] diff --git a/zerver/webhooks/front/view.py b/zerver/webhooks/front/view.py index 94cfe9e98c..9384afc7de 100644 --- a/zerver/webhooks/front/view.py +++ b/zerver/webhooks/front/view.py @@ -60,9 +60,7 @@ def get_outbound_message_body(payload: WildValue) -> str: def get_outbound_reply_body(payload: WildValue) -> str: link, outbox, inbox, subject = get_message_data(payload) - return "[Outbound reply]({link}) from **{inbox}** to **{outbox}**.".format( - link=link, inbox=inbox, outbox=outbox - ) + return f"[Outbound reply]({link}) from **{inbox}** to **{outbox}**." def get_comment_body(payload: WildValue) -> str: @@ -78,9 +76,7 @@ def get_conversation_assigned_body(payload: WildValue) -> str: if source_name == target_name: return f"**{source_name}** assigned themselves." - return "**{source_name}** assigned **{target_name}**.".format( - source_name=source_name, target_name=target_name - ) + return f"**{source_name}** assigned **{target_name}**." def get_conversation_unassigned_body(payload: WildValue) -> str: diff --git a/zerver/webhooks/groove/view.py b/zerver/webhooks/groove/view.py index 792f137b5c..849867b918 100644 --- a/zerver/webhooks/groove/view.py +++ b/zerver/webhooks/groove/view.py @@ -66,9 +66,7 @@ def ticket_assigned_body(payload: WildValue) -> Optional[str]: if assignee or assigned_group: if assignee and assigned_group: - kwargs["assignee_info"] = "{assignee} from {assigned_group}".format( - assignee=assignee, assigned_group=assigned_group - ) + kwargs["assignee_info"] = f"{assignee} from {assigned_group}" elif assignee: kwargs["assignee_info"] = f"{assignee}" elif assigned_group: