diff --git a/scripts/lib/unpack-zulip b/scripts/lib/unpack-zulip index b9d458817a..1102e3fd1b 100755 --- a/scripts/lib/unpack-zulip +++ b/scripts/lib/unpack-zulip @@ -36,7 +36,7 @@ current_version = version.ZULIP_VERSION if is_invalid_upgrade(current_version, new_version): print( FAIL + "Your current version is very old. Please first upgrade to version " - "1.4.3 and then upgrade to {}.".format(new_version) + ENDC + f"1.4.3 and then upgrade to {new_version}." + ENDC ) shutil.rmtree(extract_path) sys.exit(1) diff --git a/tools/droplets/add_mentor.py b/tools/droplets/add_mentor.py index e11986e01e..6f113ec79a 100644 --- a/tools/droplets/add_mentor.py +++ b/tools/droplets/add_mentor.py @@ -52,7 +52,7 @@ if __name__ == "__main__": if args.remove: remove_re = re.compile( - "#<{0}>{{{{.+}}}}<{0}>(\n)?".format(args.username), re.DOTALL | re.MULTILINE + rf"#<{args.username}>{{{{.+}}}}<{args.username}>(\n)?", re.DOTALL | re.MULTILINE ) with open(authorized_keys, "r+") as f: diff --git a/tools/droplets/create.py b/tools/droplets/create.py index c9e0427ca4..64aa03d347 100644 --- a/tools/droplets/create.py +++ b/tools/droplets/create.py @@ -97,8 +97,8 @@ def assert_droplet_does_not_exist(my_token: str, droplet_name: str, recreate: bo if droplet.name.lower() == droplet_name: if not recreate: print( - "Droplet {} already exists. Pass --recreate if you " - "need to recreate the droplet.".format(droplet_name) + f"Droplet {droplet_name} already exists. Pass --recreate if you " + "need to recreate the droplet." ) sys.exit(1) else: @@ -251,8 +251,8 @@ def create_dns_record(my_token: str, record_name: str, ipv4: str, ipv6: str) -> def print_dev_droplet_instructions(username: str, droplet_domain_name: str) -> None: print( - """ -COMPLETE! Droplet for GitHub user {0} is available at {1}. + f""" +COMPLETE! Droplet for GitHub user {username} is available at {droplet_domain_name}. Instructions for use are below. (copy and paste to the user) @@ -260,16 +260,14 @@ Instructions for use are below. (copy and paste to the user) Your remote Zulip dev server has been created! - Connect to your server by running - `ssh zulipdev@{1}` on the command line + `ssh zulipdev@{droplet_domain_name}` on the command line (Terminal for macOS and Linux, Bash for Git on Windows). - There is no password; your account is configured to use your SSH keys. - Once you log in, you should see `(zulip-py3-venv) ~$`. - To start the dev server, `cd zulip` and then run `./tools/run-dev`. - While the dev server is running, you can see the Zulip server in your browser at - http://{1}:9991. -""".format( - username, droplet_domain_name - ) + http://{droplet_domain_name}:9991. +""" ) print( diff --git a/tools/generate-integration-docs-screenshot b/tools/generate-integration-docs-screenshot index 9acc395fd3..52e761fd7e 100755 --- a/tools/generate-integration-docs-screenshot +++ b/tools/generate-integration-docs-screenshot @@ -130,8 +130,8 @@ def custom_headers(headers_json: str) -> Dict[str, str]: return orjson.loads(headers_json) except orjson.JSONDecodeError as ve: raise argparse.ArgumentTypeError( - "Encountered an error while attempting to parse custom headers: {}\n" - "Note: all strings must be enclosed within \"\" instead of ''".format(ve) + f"Encountered an error while attempting to parse custom headers: {ve}\n" + "Note: all strings must be enclosed within \"\" instead of ''" ) @@ -156,10 +156,8 @@ def send_bot_mock_message( client.send_message(request) except KeyError: print( - "{} contains invalid configuration. " - 'Fields "subject" and "body" are required for non-webhook integrations.'.format( - fixture_path - ) + f"{fixture_path} contains invalid configuration. " + 'Fields "subject" and "body" are required for non-webhook integrations.' ) sys.exit(1) diff --git a/zerver/lib/bot_config.py b/zerver/lib/bot_config.py index d1097e05e6..aa3a0e9708 100644 --- a/zerver/lib/bot_config.py +++ b/zerver/lib/bot_config.py @@ -55,10 +55,8 @@ def set_bot_config(bot_profile: UserProfile, key: str, value: str) -> None: new_config_size = old_config_size + (new_entry_size - old_entry_size) if new_config_size > config_size_limit: raise ConfigError( - "Cannot store configuration. Request would require {} characters. " - "The current configuration size limit is {} characters.".format( - new_config_size, config_size_limit - ) + f"Cannot store configuration. Request would require {new_config_size} characters. " + f"The current configuration size limit is {config_size_limit} characters." ) obj, created = BotConfigData.objects.get_or_create( bot_profile=bot_profile, key=key, defaults={"value": value} diff --git a/zerver/lib/zcommand.py b/zerver/lib/zcommand.py index e29335499b..a92b40a301 100644 --- a/zerver/lib/zcommand.py +++ b/zerver/lib/zcommand.py @@ -11,13 +11,7 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any] def change_mode_setting( setting_name: str, switch_command: str, setting: str, setting_value: int ) -> str: - msg = ( - "Changed to {setting_name}! To revert " - "{setting_name}, type `/{switch_command}`.".format( - setting_name=setting_name, - switch_command=switch_command, - ) - ) + msg = f"Changed to {setting_name}! To revert {setting_name}, type `/{switch_command}`." do_change_user_setting( user_profile=user_profile, setting_name=setting, diff --git a/zerver/management/commands/send_webhook_fixture_message.py b/zerver/management/commands/send_webhook_fixture_message.py index 609b648373..5f8524dce7 100644 --- a/zerver/management/commands/send_webhook_fixture_message.py +++ b/zerver/management/commands/send_webhook_fixture_message.py @@ -56,8 +56,8 @@ approach shown above. custom_headers_dict = orjson.loads(custom_headers) except orjson.JSONDecodeError as ve: raise CommandError( - "Encountered an error while attempting to parse custom headers: {}\n" - "Note: all strings must be enclosed within \"\" instead of ''".format(ve) + f"Encountered an error while attempting to parse custom headers: {ve}\n" + "Note: all strings must be enclosed within \"\" instead of ''" ) return standardize_headers(custom_headers_dict) diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index c6c37a2d5f..73a4298f11 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -1719,9 +1719,9 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase, ABC): self.assertEqual(result.status_code, 200) self.assert_in_response('action="/register/"', result) self.assert_in_response( - "Your email address, {}, is not " + f"Your email address, {email}, is not " "in one of the domains that are allowed to register " - "for accounts in this organization.".format(email), + "for accounts in this organization.", result, ) diff --git a/zerver/tests/test_markdown.py b/zerver/tests/test_markdown.py index 1459e37876..1d06850df3 100644 --- a/zerver/tests/test_markdown.py +++ b/zerver/tests/test_markdown.py @@ -2543,12 +2543,12 @@ class MarkdownTest(ZulipTestCase): render_markdown(msg, content).rendered_content, "
Look to " '#{denmark.name} and ' + f'data-stream-id="{denmark.id}" ' + f'href="/#narrow/stream/{denmark.id}-Denmark">#{denmark.name} and ' '#{scotland.name}, ' - "there something
".format(denmark=denmark, scotland=scotland), + f'data-stream-id="{scotland.id}" ' + f'href="/#narrow/stream/{scotland.id}-Scotland">#{scotland.name}, ' + "there something", ) def test_stream_case_sensitivity(self) -> None: @@ -2622,14 +2622,14 @@ class MarkdownTest(ZulipTestCase): self.assertEqual( render_markdown(msg, content).rendered_content, "This has two links: " - '' - "#{denmark.name} > some topic" + f'' + f"#{denmark.name} > some topic" " and " - '' - "#{scotland.name} > other topic" - ".
".format(denmark=denmark, scotland=scotland), + f'' + f"#{scotland.name} > other topic" + ".", ) def test_possible_stream_names(self) -> None: @@ -2652,10 +2652,7 @@ class MarkdownTest(ZulipTestCase): href = f"/#narrow/stream/{uni.id}-{quoted_name}" self.assertEqual( render_markdown(msg, content).rendered_content, - ''.format( - s=uni, - href=href, - ), + f'', ) def test_stream_atomic_string(self) -> None: diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py index d4ffd76c78..ac2d92c3e5 100644 --- a/zerver/tests/test_message_send.py +++ b/zerver/tests/test_message_send.py @@ -1501,8 +1501,7 @@ class StreamMessagesTest(ZulipTestCase): message = most_recent_message(receiving_user_profile) self.assertEqual( repr(message), - "