Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
ruff: Fix FLY002 Consider f"…" instead of string join.
Anders Kaseorg55aa29bef450
diff --git a/pyproject.toml b/pyproject.tomlindex 065b68e92c4..86ac25c3e7d 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -102,6 +102,7 @@ select = ["E", # style errors"EXE", # shebang"F", # flakes+ "FLY", # string formatting"G", # logging format"I", # import sorting"INT", # gettextdiff --git a/tools/webpack b/tools/webpackindex aac626df4c0..ef7ef5033f2 100755--- a/tools/webpack+++ b/tools/webpack@@ -58,7 +58,7 @@ def build_for_dev_server(host: str, port: str, minify: bool, disable_host_check:if disable_host_check:webpack_args.append("--allowed-hosts=all")else:- webpack_args.append("--allowed-hosts=" + ",".join([host, ".zulipdev.com", ".zulipdev.org"]))+ webpack_args.append(f"--allowed-hosts={host},.zulipdev.com,.zulipdev.org")# Tell webpack-dev-server to fall back to periodic polling on# filesystems where inotify is known to be broken.diff --git a/zerver/lib/request.py b/zerver/lib/request.pyindex 03b4732d64a..c03acacf182 100644--- a/zerver/lib/request.py+++ b/zerver/lib/request.py@@ -347,7 +347,7 @@ def has_request_variables(post_params = []- view_func_full_name = ".".join([req_func.__module__, req_func.__name__])+ view_func_full_name = f"{req_func.__module__}.{req_func.__name__}"for name, value in zip(default_param_names, default_param_values):if isinstance(value, _REQ):diff --git a/zerver/lib/upload/local.py b/zerver/lib/upload/local.pyindex d5b0cbb5967..84e8c04f40f 100644--- a/zerver/lib/upload/local.py+++ b/zerver/lib/upload/local.py@@ -236,7 +236,7 @@ class LocalUploadBackend(ZulipUploadBackend):)image_data = emoji_file.read()- write_local_file("avatars", ".".join((emoji_path, "original")), image_data)+ write_local_file("avatars", f"{emoji_path}.original", image_data)resized_image_data, is_animated, still_image_data = resize_emoji(image_data)write_local_file("avatars", emoji_path, resized_image_data)if is_animated:diff --git a/zerver/lib/upload/s3.py b/zerver/lib/upload/s3.pyindex 669f4e3eea9..ca547447f5a 100644--- a/zerver/lib/upload/s3.py+++ b/zerver/lib/upload/s3.py@@ -456,7 +456,7 @@ class S3UploadBackend(ZulipUploadBackend):image_data = emoji_file.read()upload_image_to_s3(self.avatar_bucket,- ".".join((emoji_path, "original")),+ f"{emoji_path}.original",content_type,user_profile,image_data,diff --git a/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py b/zerver/migrations/0149_realm_emoji_drop_unique_constraint.pyindex 51a1172a057..bbd6236ed66 100644--- a/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py+++ b/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py@@ -82,7 +82,7 @@ def get_uploader() -> Uploader:def get_emoji_file_name(emoji_file_name: str, new_name: str) -> str:_, image_ext = os.path.splitext(emoji_file_name)- return "".join((new_name, image_ext))+ return f"{new_name}{image_ext}"def migrate_realm_emoji_image_files(diff --git a/zerver/tests/test_invite.py b/zerver/tests/test_invite.pyindex e1142db4f69..f52090fe15a 100644--- a/zerver/tests/test_invite.py+++ b/zerver/tests/test_invite.py@@ -556,7 +556,7 @@ class InviteUserTest(InviteUserBase):cross_realm_bot_email = "[email protected]"legit_new_email = "[email protected]"- invitee_emails = ",".join([cross_realm_bot_email, legit_new_email])+ invitee_emails = f"{cross_realm_bot_email},{legit_new_email}"result = self.invite(invitee_emails, ["Denmark"])self.assert_json_error(diff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.pyindex ecbf55f58d3..197b082e892 100644--- a/zerver/tests/test_message_fetch.py+++ b/zerver/tests/test_message_fetch.py@@ -326,11 +326,8 @@ class NarrowBuilderTest(ZulipTestCase):)def test_add_term_using_dm_operator_and_self_and_user_as_operand(self) -> None:- myself_and_other = ",".join(- [- self.example_user("hamlet").email,- self.example_user("othello").email,- ]+ myself_and_other = (+ f"{self.example_user('hamlet').email},{self.example_user('othello').email}")term = dict(operator="dm", operand=myself_and_other)self._do_add_term_test(@@ -339,23 +336,15 @@ class NarrowBuilderTest(ZulipTestCase):)def test_add_term_using_dm_operator_more_than_one_user_as_operand(self) -> None:- two_others = ",".join(- [- self.example_user("cordelia").email,- self.example_user("othello").email,- ]- )+ two_others = f"{self.example_user('cordelia').email},{self.example_user('othello').email}"term = dict(operator="dm", operand=two_others)self._do_add_term_test(term, "WHERE recipient_id = %(recipient_id_1)s")def test_add_term_using_dm_operator_self_and_user_as_operand_and_negated(self,) -> None: # NEGATED- myself_and_other = ",".join(- [- self.example_user("hamlet").email,- self.example_user("othello").email,- ]+ myself_and_other = (+ f"{self.example_user('hamlet').email},{self.example_user('othello').email}")term = dict(operator="dm", operand=myself_and_other, negated=True)self._do_add_term_test(@@ -366,12 +355,7 @@ class NarrowBuilderTest(ZulipTestCase):def test_add_term_using_dm_operator_more_than_one_user_as_operand_and_negated(self,) -> None: # NEGATED- two_others = ",".join(- [- self.example_user("cordelia").email,- self.example_user("othello").email,- ]- )+ two_others = f"{self.example_user('cordelia').email},{self.example_user('othello').email}"term = dict(operator="dm", operand=two_others, negated=True)self._do_add_term_test(term, "WHERE recipient_id != %(recipient_id_1)s")