mirror of https://github.com/zulip/zulip.git
ruff: Fix UP032 Use f-string instead of `format` call.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
0efc662eab
commit
50e6cba1af
|
@ -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-")
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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])
|
||||
|
||||
|
|
|
@ -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 = []
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue