diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py index 84addc5af5..af87512ca0 100644 --- a/corporate/lib/stripe.py +++ b/corporate/lib/stripe.py @@ -2240,7 +2240,7 @@ class BillingSession(ABC): # Should do this in JavaScript, using the user's time zone if plan.is_free_trial() or downgrade_at_end_of_free_trial: assert plan.next_invoice_date is not None - renewal_date = "{dt:%B} {dt.day}, {dt.year}".format(dt=plan.next_invoice_date) + renewal_date = f"{plan.next_invoice_date:%B} {plan.next_invoice_date.day}, {plan.next_invoice_date.year}" else: renewal_date = "{dt:%B} {dt.day}, {dt.year}".format( dt=start_of_next_billing_cycle(plan, now) diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index 1287fa354b..fdfe5206ed 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -563,10 +563,10 @@ def assert_not_running_as_root() -> None: if is_root(): pwent = get_zulip_pwent() msg = ( - "{shortname} should not be run as root. Use `su {user}` to switch to the 'zulip'\n" - "user before rerunning this, or use \n su {user} -c '{name} ...'\n" + f"{os.path.basename(script_name)} should not be run as root. Use `su {pwent.pw_name}` to switch to the 'zulip'\n" + f"user before rerunning this, or use \n su {pwent.pw_name} -c '{script_name} ...'\n" "to switch users and run this as a single command." - ).format(name=script_name, shortname=os.path.basename(script_name), user=pwent.pw_name) + ) print(msg) sys.exit(1) diff --git a/tools/lib/provision.py b/tools/lib/provision.py index 82d898164d..154958b97f 100755 --- a/tools/lib/provision.py +++ b/tools/lib/provision.py @@ -45,9 +45,7 @@ with open("/proc/meminfo") as meminfo: ram_gb = float(ram_size) / 1024.0 / 1024.0 if ram_gb < 1.5: print( - "You have insufficient RAM ({} GB) to run the Zulip development environment.".format( - round(ram_gb, 2) - ) + f"You have insufficient RAM ({round(ram_gb, 2)} GB) to run the Zulip development environment." ) print("We recommend at least 2 GB of RAM, and require at least 1.5 GB.") sys.exit(1) diff --git a/zerver/actions/create_realm.py b/zerver/actions/create_realm.py index 8e264c157f..affb079190 100644 --- a/zerver/actions/create_realm.py +++ b/zerver/actions/create_realm.py @@ -325,13 +325,7 @@ def do_create_realm( support_url = get_realm_support_url(realm) organization_type = get_org_type_display_name(realm.org_type) - message = "[{name}]({support_link}) ([{subdomain}]({realm_link})). Organization type: {type}".format( - name=realm.name, - subdomain=realm.display_subdomain, - realm_link=realm.uri, - support_link=support_url, - type=organization_type, - ) + message = f"[{realm.name}]({support_url}) ([{realm.display_subdomain}]({realm.uri})). Organization type: {organization_type}" topic_name = "new organizations" try: diff --git a/zerver/lib/bot_storage.py b/zerver/lib/bot_storage.py index 7b3a9163da..0dccb96a2b 100644 --- a/zerver/lib/bot_storage.py +++ b/zerver/lib/bot_storage.py @@ -45,9 +45,7 @@ def set_bot_storage(bot_profile: UserProfile, entries: List[Tuple[str, str]]) -> new_storage_size = get_bot_storage_size(bot_profile) + storage_size_difference if new_storage_size > storage_size_limit: raise StateError( - "Request exceeds storage limit by {} characters. The limit is {} characters.".format( - new_storage_size - storage_size_limit, storage_size_limit - ) + f"Request exceeds storage limit by {new_storage_size - storage_size_limit} characters. The limit is {storage_size_limit} characters." ) else: for key, value in entries: diff --git a/zerver/lib/email_mirror.py b/zerver/lib/email_mirror.py index d29a65943e..dd06f16330 100644 --- a/zerver/lib/email_mirror.py +++ b/zerver/lib/email_mirror.py @@ -205,9 +205,7 @@ def send_mm_reply_to_stream( message_content=body, ) except JsonableError as error: - error_message = "Error sending message to stream {stream} via message notification email reply:\n{error}".format( - stream=stream.name, error=error.msg - ) + error_message = f"Error sending message to stream {stream.name} via message notification email reply:\n{error.msg}" internal_send_private_message( get_system_bot(settings.NOTIFICATION_BOT, user_profile.realm_id), user_profile, diff --git a/zerver/management/commands/deactivate_user.py b/zerver/management/commands/deactivate_user.py index 6234daa54c..63f0f42ee8 100644 --- a/zerver/management/commands/deactivate_user.py +++ b/zerver/management/commands/deactivate_user.py @@ -37,10 +37,7 @@ class Command(ZulipBaseCommand): print(session.expire_date, session.get_decoded()) print("") print( - "{} has {} active bots that will also be deactivated.".format( - user_profile.delivery_email, - get_active_bots_owned_by_user(user_profile).count(), - ) + f"{user_profile.delivery_email} has {get_active_bots_owned_by_user(user_profile).count()} active bots that will also be deactivated." ) if not options["for_real"]: diff --git a/zerver/management/commands/delete_user.py b/zerver/management/commands/delete_user.py index 9e32ed31df..dff58d3880 100644 --- a/zerver/management/commands/delete_user.py +++ b/zerver/management/commands/delete_user.py @@ -57,10 +57,7 @@ This will: for user_profile in user_profiles: print( - "{} has {} active bots that will be deactivated as a result of the user's deletion.".format( - user_profile.delivery_email, - get_active_bots_owned_by_user(user_profile).count(), - ) + f"{user_profile.delivery_email} has {get_active_bots_owned_by_user(user_profile).count()} active bots that will be deactivated as a result of the user's deletion." ) if not options["for_real"]: diff --git a/zerver/tests/test_markdown.py b/zerver/tests/test_markdown.py index 9610ee7788..b50a511f24 100644 --- a/zerver/tests/test_markdown.py +++ b/zerver/tests/test_markdown.py @@ -2875,9 +2875,7 @@ class MarkdownTest(ZulipTestCase): content = "#**Denmark**" self.assertEqual( render_message_markdown(msg, content).rendered_content, - '
'.format( - d=denmark, - ), + f'', ) def test_invalid_stream_followed_by_valid_mention(self) -> None: @@ -2891,9 +2889,7 @@ class MarkdownTest(ZulipTestCase): content = "#**Invalid** and #**Denmark**" self.assertEqual( render_message_markdown(msg, content).rendered_content, - '#Invalid and #{d.name}
'.format( - d=denmark, - ), + f'#Invalid and #{denmark.name}
', ) def test_stream_multiple(self) -> None: @@ -2927,9 +2923,7 @@ class MarkdownTest(ZulipTestCase): content = "#**CaseSens**" self.assertEqual( render_message_markdown(msg, content).rendered_content, - ''.format( - s=case_sens, - ), + f'', ) def test_stream_case_sensitivity_nonmatching(self) -> None: @@ -2957,9 +2951,7 @@ class MarkdownTest(ZulipTestCase): content = "#**Denmark>some topic**" self.assertEqual( render_message_markdown(msg, content).rendered_content, - ''.format( - d=denmark, - ), + f'', ) def test_topic_atomic_string(self) -> None: @@ -2981,9 +2973,7 @@ class MarkdownTest(ZulipTestCase): content = "#**Denmark>#1234**" self.assertEqual( render_message_markdown(msg, content).rendered_content, - ''.format( - d=denmark, - ), + f'', ) def test_topic_multiple(self) -> None: @@ -3052,10 +3042,7 @@ class MarkdownTest(ZulipTestCase): href = f"/#narrow/stream/{stream.id}-Stream-.231234" self.assertEqual( render_message_markdown(msg, content).rendered_content, - ''.format( - s=stream, - href=href, - ), + f'', ) def test_stream_invalid(self) -> None: diff --git a/zerver/tests/test_retention.py b/zerver/tests/test_retention.py index 86cc15f0c0..2cb90a95a3 100644 --- a/zerver/tests/test_retention.py +++ b/zerver/tests/test_retention.py @@ -194,10 +194,10 @@ class ArchiveMessagesTestingBase(RetentionTestingBase): self.subscribe(user_profile, "Denmark") body = ( "Some files here ..." - " [zulip.txt](http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/zulip.txt)" - " http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/temp_file.py.... Some" - " more.... http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py" - ).format(id=realm_id, host=host) + f" [zulip.txt](http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/zulip.txt)" + f" http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/temp_file.py.... Some" + f" more.... http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py" + ) expired_message_id = self.send_stream_message(user_profile, "Denmark", body) actual_message_id = self.send_stream_message(user_profile, "Denmark", body) @@ -754,13 +754,13 @@ class MoveMessageToArchiveGeneral(MoveMessageToArchiveBase): self._create_attachments() realm_id = get_realm("zulip").id host = get_realm("zulip").host - body = """Some files here ...[zulip.txt]( - http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/zulip.txt) - http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/temp_file.py .... - Some more.... http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py ... - http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/new.py .... - http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/hello.txt .... - """.format(id=realm_id, host=host) + body = f"""Some files here ...[zulip.txt]( + http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/zulip.txt) + http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/temp_file.py .... + Some more.... http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py ... + http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/new.py .... + http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/hello.txt .... + """ msg_id = self.send_personal_message(self.sender, self.recipient, body) # Simulate a reply with the same contents. @@ -813,13 +813,13 @@ class MoveMessageToArchiveGeneral(MoveMessageToArchiveBase): self._create_attachments() realm_id = get_realm("zulip").id host = get_realm("zulip").host - body = """Some files here ...[zulip.txt]( - http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/zulip.txt) - http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/temp_file.py .... - Some more.... http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py ... - http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/new.py .... - http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/hello.txt .... - """.format(id=realm_id, host=host) + body = f"""Some files here ...[zulip.txt]( + http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/zulip.txt) + http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/temp_file.py .... + Some more.... http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py ... + http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/new.py .... + http://{host}/user_uploads/{realm_id}/31/4CBjtTLYZhk66pZrF8hnYGwc/hello.txt .... + """ msg_id = self.send_personal_message(self.sender, self.recipient, body) diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index 4457db2d1e..a57505cf06 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -3274,9 +3274,7 @@ class DefaultStreamGroupTest(ZulipTestCase): ) self.assert_json_error( result, - "Default stream group name too long (limit: {} characters)".format( - DefaultStreamGroup.MAX_NAME_LENGTH - ), + f"Default stream group name too long (limit: {DefaultStreamGroup.MAX_NAME_LENGTH} characters)", ) result = self.client_post(