From 56f6656d8b219a0ee4bf4b29e1b3b4166b79f355 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Bodas Date: Thu, 10 Jun 2021 19:51:09 +0530 Subject: [PATCH] message send: Don't create user data list with inline `for`. This will make the code more readable, and will allow creating local variables within the loop for reuse. --- zerver/lib/actions.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 0bc909f422..1337c77337 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -1972,18 +1972,19 @@ def do_send_messages( else: user_list = list(user_ids) - users = [ - dict( - id=user_id, - flags=user_flags.get(user_id, []), - online_push_enabled=(user_id in send_request.online_push_user_ids), - stream_push_notify=(user_id in send_request.stream_push_user_ids), - stream_email_notify=(user_id in send_request.stream_email_user_ids), - wildcard_mention_notify=(user_id in send_request.wildcard_mention_user_ids), - sender_is_muted=(user_id in send_request.muted_sender_user_ids), + users: List[Dict[str, Union[int, List[str], bool]]] = [] + for user_id in user_list: + users.append( + dict( + id=user_id, + flags=user_flags.get(user_id, []), + online_push_enabled=(user_id in send_request.online_push_user_ids), + stream_push_notify=(user_id in send_request.stream_push_user_ids), + stream_email_notify=(user_id in send_request.stream_email_user_ids), + wildcard_mention_notify=(user_id in send_request.wildcard_mention_user_ids), + sender_is_muted=(user_id in send_request.muted_sender_user_ids), + ) ) - for user_id in user_list - ] if send_request.message.is_stream_message(): # Note: This is where authorization for single-stream