From 6aedfe64572361f0e71ed6c2ff7e5d0221788257 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 11 Nov 2023 12:13:08 -0800 Subject: [PATCH] python: Fix PAR002 Dont use parentheses for unpacking. Signed-off-by: Anders Kaseorg --- .../jabber/jabber_mirror_backend.py | 2 +- zulip/integrations/zephyr/check-mirroring | 10 +++++----- zulip/integrations/zephyr/zephyr_mirror.py | 2 +- .../zephyr/zephyr_mirror_backend.py | 20 +++++++++---------- zulip/zulip/__init__.py | 2 +- .../bots/google_translate/google_translate.py | 2 +- .../zulip_bots/bots/incident/incident.py | 2 +- .../bots/trivia_quiz/trivia_quiz.py | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/zulip/integrations/jabber/jabber_mirror_backend.py b/zulip/integrations/jabber/jabber_mirror_backend.py index 43b39cf81..fb3919441 100755 --- a/zulip/integrations/jabber/jabber_mirror_backend.py +++ b/zulip/integrations/jabber/jabber_mirror_backend.py @@ -372,7 +372,7 @@ def config_error(msg: str) -> None: parser.add_option_group(jabber_group) parser.add_option_group(zulip.generate_option_group(parser, "zulip-")) - (options, args) = parser.parse_args() + options, args = parser.parse_args() logging.basicConfig(level=options.log_level, format="%(levelname)-8s %(message)s") diff --git a/zulip/integrations/zephyr/check-mirroring b/zulip/integrations/zephyr/check-mirroring index b6477fdf3..0876ec2b6 100755 --- a/zulip/integrations/zephyr/check-mirroring +++ b/zulip/integrations/zephyr/check-mirroring @@ -16,7 +16,7 @@ parser = optparse.OptionParser() parser.add_option("--verbose", dest="verbose", default=False, action="store_true") parser.add_option("--site", dest="site", default=None, action="store") parser.add_option("--sharded", default=False, action="store_true") -(options, args) = parser.parse_args() +options, args = parser.parse_args() mit_user = "tabbott/extra@ATHENA.MIT.EDU" @@ -331,8 +331,8 @@ z_contents = [ notice.z_message[: notice.z_message_len].split(b"\0")[1].decode(errors="replace") for notice in notices ] -(h_key_counts, h_missing_z, h_missing_h, h_duplicates, h_success) = process_keys(h_contents) -(z_key_counts, z_missing_z, z_missing_h, z_duplicates, z_success) = process_keys(z_contents) +h_key_counts, h_missing_z, h_missing_h, h_duplicates, h_success = process_keys(h_contents) +z_key_counts, z_missing_z, z_missing_h, z_duplicates, z_success = process_keys(z_contents) for notice in notices: zephyr_ctypes.ZFreeNotice(byref(notice)) @@ -350,7 +350,7 @@ for key in all_keys: if z_key_counts[key] == 1 and h_key_counts[key] == 1: continue if key in zhkeys: - (stream, test) = zhkeys[key] + stream, test = zhkeys[key] logger.warning( "%10s: z got %s, h got %s. Sent via Zephyr(%s): class %s", key, @@ -360,7 +360,7 @@ for key in all_keys: stream, ) if key in hzkeys: - (stream, test) = hzkeys[key] + stream, test = hzkeys[key] logger.warning( "%10s: z got %s. h got %s. Sent via Zulip(%s): class %s", key, diff --git a/zulip/integrations/zephyr/zephyr_mirror.py b/zulip/integrations/zephyr/zephyr_mirror.py index e0bd91236..f999e0a43 100755 --- a/zulip/integrations/zephyr/zephyr_mirror.py +++ b/zulip/integrations/zephyr/zephyr_mirror.py @@ -12,7 +12,7 @@ sys.path[:0] = [os.path.dirname(__file__)] from zephyr_mirror_backend import parse_args -(options, args) = parse_args() +options, args = parse_args() def die(signal: int, frame: Optional[FrameType]) -> None: diff --git a/zulip/integrations/zephyr/zephyr_mirror_backend.py b/zulip/integrations/zephyr/zephyr_mirror_backend.py index 6282e628b..10f1cf537 100755 --- a/zulip/integrations/zephyr/zephyr_mirror_backend.py +++ b/zulip/integrations/zephyr/zephyr_mirror_backend.py @@ -53,9 +53,9 @@ def make_zulip_client() -> zulip.Client: def to_zulip_username(zephyr_username: str) -> str: if "@" in zephyr_username: - (user, realm) = zephyr_username.split("@") + user, realm = zephyr_username.split("@") else: - (user, realm) = (zephyr_username, "ATHENA.MIT.EDU") + user, realm = (zephyr_username, "ATHENA.MIT.EDU") if realm.upper() == "ATHENA.MIT.EDU": # Hack to make ctl's fake username setup work :) if user.lower() == "golem": @@ -65,7 +65,7 @@ def to_zulip_username(zephyr_username: str) -> str: def to_zephyr_username(zulip_username: str) -> str: - (user, realm) = zulip_username.split("@") + user, realm = zulip_username.split("@") if "|" not in user: # Hack to make ctl's fake username setup work :) if user.lower() == "ctl": @@ -358,7 +358,7 @@ def process_loop(zulip_queue: "Queue[ZephyrDict]", log: Optional[IO[str]]) -> No def parse_zephyr_body(zephyr_data: str, notice_format: str) -> Tuple[str, str]: try: - (zsig, body) = zephyr_data.split("\x00", 1) + zsig, body = zephyr_data.split("\x00", 1) if notice_format in ( "New transaction [$1] entered in $2\nFrom: $3 ($5)\nSubject: $4", "New transaction [$1] entered in $2\nFrom: $3\nSubject: $4", @@ -374,7 +374,7 @@ def parse_zephyr_body(zephyr_data: str, notice_format: str) -> Tuple[str, str]: fields[3], ) except ValueError: - (zsig, body) = ("", zephyr_data) + zsig, body = "", zephyr_data # Clean body of any null characters, since they're invalid in our protocol. body = body.replace("\x00", "") return (zsig, body) @@ -448,7 +448,7 @@ def process_notice( notice: zephyr_ctypes.ZNotice_t, zulip_queue: "Queue[ZephyrDict]", log: Optional[IO[str]] ) -> None: assert notice.z_sender is not None - (zsig, body) = parse_zephyr_body( + zsig, body = parse_zephyr_body( notice.z_message[: notice.z_message_len].decode(errors="replace"), notice.z_default_format.decode(errors="replace"), ) @@ -852,7 +852,7 @@ class and your mirroring bot does not have access to the relevant \ logger.debug("Would have forwarded: %r\n%s", zwrite_args, wrapped_content) return - (code, stderr) = send_authed_zephyr(zwrite_args, wrapped_content) + code, stderr = send_authed_zephyr(zwrite_args, wrapped_content) if code == 0 and stderr == "": return elif code == 0: @@ -876,7 +876,7 @@ class and your mirroring bot does not have access to the relevant \ ): # Retry sending the message unauthenticated; if that works, # just notify the user that they need to renew their tickets - (code, stderr) = send_unauthed_zephyr(zwrite_args, wrapped_content) + code, stderr = send_unauthed_zephyr(zwrite_args, wrapped_content) if code == 0: if options.ignore_expired_tickets: return @@ -1106,7 +1106,7 @@ def parse_zephyr_subs(verbose: bool = False) -> Set[Tuple[str, str, str]]: if len(line) == 0: continue try: - (cls, instance, recipient) = line.split(",") + cls, instance, recipient = line.split(",") cls = cls.replace("%me%", options.user) instance = instance.replace("%me%", options.user) recipient = recipient.replace("%me%", options.user) @@ -1252,7 +1252,7 @@ def die_gracefully(signal: int, frame: Optional[FrameType]) -> None: signal.signal(signal.SIGINT, die_gracefully) - (options, args) = parse_args() + options, args = parse_args() logger = open_logger() configure_logger(logger, "parent") diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index 8c2c49e2c..5b7829b70 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -743,7 +743,7 @@ def do_register() -> Tuple[str, int]: # making a new long-polling request. while True: if queue_id is None: - (queue_id, last_event_id) = do_register() + queue_id, last_event_id = do_register() try: res = self.get_events(queue_id=queue_id, last_event_id=last_event_id) diff --git a/zulip_bots/zulip_bots/bots/google_translate/google_translate.py b/zulip_bots/zulip_bots/bots/google_translate/google_translate.py index 9bc6f29a8..78bfb33ff 100644 --- a/zulip_bots/zulip_bots/bots/google_translate/google_translate.py +++ b/zulip_bots/zulip_bots/bots/google_translate/google_translate.py @@ -93,7 +93,7 @@ def get_translate_bot_response(message_content, config_file, author, all_languag split_text.append("") if len(split_text) != 3: return help_text - (text_to_translate, target_language, source_language) = split_text + text_to_translate, target_language, source_language = split_text text_to_translate = text_to_translate[1:] target_language = get_code_for_language(target_language, all_languages) if target_language == "": diff --git a/zulip_bots/zulip_bots/bots/incident/incident.py b/zulip_bots/zulip_bots/bots/incident/incident.py index 59a247643..fd1dc07ce 100644 --- a/zulip_bots/zulip_bots/bots/incident/incident.py +++ b/zulip_bots/zulip_bots/bots/incident/incident.py @@ -34,7 +34,7 @@ def handle_message(self, message: Dict[str, Any], bot_handler: BotHandler) -> No start_new_incident(query, message, bot_handler) elif query.startswith("answer "): try: - (ticket_id, answer) = parse_answer(query) + ticket_id, answer = parse_answer(query) except InvalidAnswerError: bot_response = "Invalid answer format" bot_handler.send_reply(message, bot_response) diff --git a/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py b/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py index 8704ec413..e1ca4ac03 100644 --- a/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py +++ b/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py @@ -35,7 +35,7 @@ def handle_message(self, message: Dict[str, Any], bot_handler: BotHandler) -> No return elif query.startswith("answer"): try: - (quiz_id, answer) = parse_answer(query) + quiz_id, answer = parse_answer(query) except InvalidAnswerError: bot_response = "Invalid answer format" bot_handler.send_reply(message, bot_response)