diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2 index 8d3d972506..bebf2708ad 100755 --- a/scripts/lib/upgrade-zulip-stage-2 +++ b/scripts/lib/upgrade-zulip-stage-2 @@ -124,7 +124,7 @@ rabbitmq_dist_listen = listening_publicly(25672) # Check the erlang magic cookie size cookie_size: Optional[int] = None if os.path.exists("/var/lib/rabbitmq/.erlang.cookie"): - with open("/var/lib/rabbitmq/.erlang.cookie", "r") as cookie_fh: + with open("/var/lib/rabbitmq/.erlang.cookie") as cookie_fh: cookie_size = len(cookie_fh.readline()) else: logging.info("No RabbitMQ erlang cookie found, not auditing RabbitMQ security.") diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 5e6d0a4164..dcf3a52a04 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -6584,7 +6584,7 @@ def maybe_send_resolve_topic_notifications( # Compute the users who either sent or reacted to messages that # were moved via the "resolve topic' action. Only those users # should be eligible for this message being managed as unread. - affected_participant_ids = (set(message.sender_id for message in changed_messages)) | set( + affected_participant_ids = {message.sender_id for message in changed_messages} | set( Reaction.objects.filter(message__in=changed_messages).values_list( "user_profile_id", flat=True ) diff --git a/zerver/migrations/0375_invalid_characters_in_stream_names.py b/zerver/migrations/0375_invalid_characters_in_stream_names.py index 129ed40e21..3d2803eec1 100644 --- a/zerver/migrations/0375_invalid_characters_in_stream_names.py +++ b/zerver/migrations/0375_invalid_characters_in_stream_names.py @@ -6,12 +6,12 @@ from django.db.migrations.state import StateApps # There are 66 Unicode non-characters; see # https://www.unicode.org/faq/private_use.html#nonchar4 -unicode_non_chars = set( +unicode_non_chars = { chr(x) for x in list(range(0xFDD0, 0xFDF0)) # FDD0 through FDEF, inclusive + list(range(0xFFFE, 0x110000, 0x10000)) # 0xFFFE, 0x1FFFE, ... 0x10FFFE inclusive + list(range(0xFFFF, 0x110000, 0x10000)) # 0xFFFF, 0x1FFFF, ... 0x10FFFF inclusive -) +} def character_is_printable(character: str) -> bool: @@ -31,7 +31,7 @@ def fix_stream_names(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> No for realm_id in realm_ids: print(f"Processing realm {realm_id}") realm_stream_dicts = Stream.objects.filter(realm_id=realm_id).values("id", "name") - occupied_stream_names = set(stream_dict["name"] for stream_dict in realm_stream_dicts) + occupied_stream_names = {stream_dict["name"] for stream_dict in realm_stream_dicts} for stream_dict in realm_stream_dicts: stream_name = stream_dict["name"] diff --git a/zerver/tests/test_message_flags.py b/zerver/tests/test_message_flags.py index 5bb2de62f2..7bbf4c8b48 100644 --- a/zerver/tests/test_message_flags.py +++ b/zerver/tests/test_message_flags.py @@ -1552,7 +1552,7 @@ class MarkUnreadTest(ZulipTestCase): self.assert_json_success(result) event = events[0]["event"] self.assertEqual(event["messages"], messages_to_unread) - unread_message_ids = set(str(message_id) for message_id in messages_to_unread) + unread_message_ids = {str(message_id) for message_id in messages_to_unread} self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids) for message_id in event["message_details"]: self.assertEqual( @@ -1625,7 +1625,7 @@ class MarkUnreadTest(ZulipTestCase): self.assert_json_success(result) event = events[0]["event"] self.assertEqual(event["messages"], messages_to_unread) - unread_message_ids = set(str(message_id) for message_id in messages_to_unread) + unread_message_ids = {str(message_id) for message_id in messages_to_unread} self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids) for message_id in event["message_details"]: self.assertEqual( @@ -1698,7 +1698,7 @@ class MarkUnreadTest(ZulipTestCase): self.assert_json_success(result) event = events[0]["event"] self.assertEqual(event["messages"], messages_to_unread) - unread_message_ids = set(str(message_id) for message_id in messages_to_unread) + unread_message_ids = {str(message_id) for message_id in messages_to_unread} self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids) for message_id in event["message_details"]: self.assertEqual( @@ -1768,7 +1768,7 @@ class MarkUnreadTest(ZulipTestCase): self.assert_json_success(result) event = events[0]["event"] self.assertEqual(event["messages"], messages_to_unread) - unread_message_ids = set(str(message_id) for message_id in messages_to_unread) + unread_message_ids = {str(message_id) for message_id in messages_to_unread} self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids) for message_id in event["message_details"]: self.assertEqual( @@ -1838,7 +1838,7 @@ class MarkUnreadTest(ZulipTestCase): self.assert_json_success(result) event = events[0]["event"] self.assertEqual(event["messages"], messages_to_unread) - unread_message_ids = set(str(message_id) for message_id in messages_to_unread) + unread_message_ids = {str(message_id) for message_id in messages_to_unread} self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids) for message_id in event["message_details"]: self.assertEqual( @@ -1909,7 +1909,7 @@ class MarkUnreadTest(ZulipTestCase): self.assert_json_success(result) event = events[0]["event"] self.assertEqual(event["messages"], messages_to_unread) - unread_message_ids = set(str(message_id) for message_id in messages_to_unread) + unread_message_ids = {str(message_id) for message_id in messages_to_unread} self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids) for message_id in event["message_details"]: self.assertNotIn("mentioned", event["message_details"][message_id]), @@ -1975,7 +1975,7 @@ class MarkUnreadTest(ZulipTestCase): self.assert_json_success(result) event = events[0]["event"] self.assertEqual(event["messages"], messages_to_unread) - unread_message_ids = set(str(message_id) for message_id in messages_to_unread) + unread_message_ids = {str(message_id) for message_id in messages_to_unread} self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids) for message_id in event["message_details"]: self.assertEqual(event["message_details"][message_id]["mentioned"], True),