diff --git a/pyproject.toml b/pyproject.toml index 065b68e92c..86ac25c3e7 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", # gettext diff --git a/tools/webpack b/tools/webpack index aac626df4c..ef7ef5033f 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.py index 03b4732d64..c03acacf18 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.py index d5b0cbb596..84e8c04f40 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.py index 669f4e3eea..ca547447f5 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.py index 51a1172a05..bbd6236ed6 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.py index e1142db4f6..f52090fe15 100644 --- a/zerver/tests/test_invite.py +++ b/zerver/tests/test_invite.py @@ -556,7 +556,7 @@ class InviteUserTest(InviteUserBase): cross_realm_bot_email = "emailgateway@zulip.com" legit_new_email = "fred@zulip.com" - 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.py index ecbf55f58d..197b082e89 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")