python: Use modern set comprehension syntax.

Generated by pyupgrade.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-03-24 19:13:54 -07:00 committed by Tim Abbott
parent 1f68c73e66
commit 55882fb343
4 changed files with 12 additions and 12 deletions

View File

@ -124,7 +124,7 @@ rabbitmq_dist_listen = listening_publicly(25672)
# Check the erlang magic cookie size # Check the erlang magic cookie size
cookie_size: Optional[int] = None cookie_size: Optional[int] = None
if os.path.exists("/var/lib/rabbitmq/.erlang.cookie"): 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()) cookie_size = len(cookie_fh.readline())
else: else:
logging.info("No RabbitMQ erlang cookie found, not auditing RabbitMQ security.") logging.info("No RabbitMQ erlang cookie found, not auditing RabbitMQ security.")

View File

@ -6584,7 +6584,7 @@ def maybe_send_resolve_topic_notifications(
# Compute the users who either sent or reacted to messages that # Compute the users who either sent or reacted to messages that
# were moved via the "resolve topic' action. Only those users # were moved via the "resolve topic' action. Only those users
# should be eligible for this message being managed as unread. # 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( Reaction.objects.filter(message__in=changed_messages).values_list(
"user_profile_id", flat=True "user_profile_id", flat=True
) )

View File

@ -6,12 +6,12 @@ from django.db.migrations.state import StateApps
# There are 66 Unicode non-characters; see # There are 66 Unicode non-characters; see
# https://www.unicode.org/faq/private_use.html#nonchar4 # https://www.unicode.org/faq/private_use.html#nonchar4
unicode_non_chars = set( unicode_non_chars = {
chr(x) chr(x)
for x in list(range(0xFDD0, 0xFDF0)) # FDD0 through FDEF, inclusive for x in list(range(0xFDD0, 0xFDF0)) # FDD0 through FDEF, inclusive
+ list(range(0xFFFE, 0x110000, 0x10000)) # 0xFFFE, 0x1FFFE, ... 0x10FFFE inclusive + list(range(0xFFFE, 0x110000, 0x10000)) # 0xFFFE, 0x1FFFE, ... 0x10FFFE inclusive
+ list(range(0xFFFF, 0x110000, 0x10000)) # 0xFFFF, 0x1FFFF, ... 0x10FFFF inclusive + list(range(0xFFFF, 0x110000, 0x10000)) # 0xFFFF, 0x1FFFF, ... 0x10FFFF inclusive
) }
def character_is_printable(character: str) -> bool: 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: for realm_id in realm_ids:
print(f"Processing realm {realm_id}") print(f"Processing realm {realm_id}")
realm_stream_dicts = Stream.objects.filter(realm_id=realm_id).values("id", "name") 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: for stream_dict in realm_stream_dicts:
stream_name = stream_dict["name"] stream_name = stream_dict["name"]

View File

@ -1552,7 +1552,7 @@ class MarkUnreadTest(ZulipTestCase):
self.assert_json_success(result) self.assert_json_success(result)
event = events[0]["event"] event = events[0]["event"]
self.assertEqual(event["messages"], messages_to_unread) 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) self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids)
for message_id in event["message_details"]: for message_id in event["message_details"]:
self.assertEqual( self.assertEqual(
@ -1625,7 +1625,7 @@ class MarkUnreadTest(ZulipTestCase):
self.assert_json_success(result) self.assert_json_success(result)
event = events[0]["event"] event = events[0]["event"]
self.assertEqual(event["messages"], messages_to_unread) 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) self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids)
for message_id in event["message_details"]: for message_id in event["message_details"]:
self.assertEqual( self.assertEqual(
@ -1698,7 +1698,7 @@ class MarkUnreadTest(ZulipTestCase):
self.assert_json_success(result) self.assert_json_success(result)
event = events[0]["event"] event = events[0]["event"]
self.assertEqual(event["messages"], messages_to_unread) 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) self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids)
for message_id in event["message_details"]: for message_id in event["message_details"]:
self.assertEqual( self.assertEqual(
@ -1768,7 +1768,7 @@ class MarkUnreadTest(ZulipTestCase):
self.assert_json_success(result) self.assert_json_success(result)
event = events[0]["event"] event = events[0]["event"]
self.assertEqual(event["messages"], messages_to_unread) 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) self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids)
for message_id in event["message_details"]: for message_id in event["message_details"]:
self.assertEqual( self.assertEqual(
@ -1838,7 +1838,7 @@ class MarkUnreadTest(ZulipTestCase):
self.assert_json_success(result) self.assert_json_success(result)
event = events[0]["event"] event = events[0]["event"]
self.assertEqual(event["messages"], messages_to_unread) 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) self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids)
for message_id in event["message_details"]: for message_id in event["message_details"]:
self.assertEqual( self.assertEqual(
@ -1909,7 +1909,7 @@ class MarkUnreadTest(ZulipTestCase):
self.assert_json_success(result) self.assert_json_success(result)
event = events[0]["event"] event = events[0]["event"]
self.assertEqual(event["messages"], messages_to_unread) 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) self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids)
for message_id in event["message_details"]: for message_id in event["message_details"]:
self.assertNotIn("mentioned", event["message_details"][message_id]), self.assertNotIn("mentioned", event["message_details"][message_id]),
@ -1975,7 +1975,7 @@ class MarkUnreadTest(ZulipTestCase):
self.assert_json_success(result) self.assert_json_success(result)
event = events[0]["event"] event = events[0]["event"]
self.assertEqual(event["messages"], messages_to_unread) 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) self.assertSetEqual(set(event["message_details"].keys()), unread_message_ids)
for message_id in event["message_details"]: for message_id in event["message_details"]:
self.assertEqual(event["message_details"][message_id]["mentioned"], True), self.assertEqual(event["message_details"][message_id]["mentioned"], True),