python: Fix PAR002 Dont use parentheses for unpacking.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-11-11 12:13:08 -08:00
parent 059458b4ca
commit 6aedfe6457
8 changed files with 21 additions and 21 deletions

View file

@ -372,7 +372,7 @@ option does not affect login credentials.""".replace("\n", " "),
parser.add_option_group(jabber_group) parser.add_option_group(jabber_group)
parser.add_option_group(zulip.generate_option_group(parser, "zulip-")) 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") logging.basicConfig(level=options.log_level, format="%(levelname)-8s %(message)s")

View file

@ -16,7 +16,7 @@ parser = optparse.OptionParser()
parser.add_option("--verbose", dest="verbose", default=False, action="store_true") parser.add_option("--verbose", dest="verbose", default=False, action="store_true")
parser.add_option("--site", dest="site", default=None, action="store") parser.add_option("--site", dest="site", default=None, action="store")
parser.add_option("--sharded", default=False, action="store_true") 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" 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") notice.z_message[: notice.z_message_len].split(b"\0")[1].decode(errors="replace")
for notice in notices for notice in notices
] ]
(h_key_counts, h_missing_z, h_missing_h, h_duplicates, h_success) = process_keys(h_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) z_key_counts, z_missing_z, z_missing_h, z_duplicates, z_success = process_keys(z_contents)
for notice in notices: for notice in notices:
zephyr_ctypes.ZFreeNotice(byref(notice)) 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: if z_key_counts[key] == 1 and h_key_counts[key] == 1:
continue continue
if key in zhkeys: if key in zhkeys:
(stream, test) = zhkeys[key] stream, test = zhkeys[key]
logger.warning( logger.warning(
"%10s: z got %s, h got %s. Sent via Zephyr(%s): class %s", "%10s: z got %s, h got %s. Sent via Zephyr(%s): class %s",
key, key,
@ -360,7 +360,7 @@ for key in all_keys:
stream, stream,
) )
if key in hzkeys: if key in hzkeys:
(stream, test) = hzkeys[key] stream, test = hzkeys[key]
logger.warning( logger.warning(
"%10s: z got %s. h got %s. Sent via Zulip(%s): class %s", "%10s: z got %s. h got %s. Sent via Zulip(%s): class %s",
key, key,

View file

@ -12,7 +12,7 @@ from typing import Optional
sys.path[:0] = [os.path.dirname(__file__)] sys.path[:0] = [os.path.dirname(__file__)]
from zephyr_mirror_backend import parse_args from zephyr_mirror_backend import parse_args
(options, args) = parse_args() options, args = parse_args()
def die(signal: int, frame: Optional[FrameType]) -> None: def die(signal: int, frame: Optional[FrameType]) -> None:

View file

@ -53,9 +53,9 @@ def make_zulip_client() -> zulip.Client:
def to_zulip_username(zephyr_username: str) -> str: def to_zulip_username(zephyr_username: str) -> str:
if "@" in zephyr_username: if "@" in zephyr_username:
(user, realm) = zephyr_username.split("@") user, realm = zephyr_username.split("@")
else: else:
(user, realm) = (zephyr_username, "ATHENA.MIT.EDU") user, realm = (zephyr_username, "ATHENA.MIT.EDU")
if realm.upper() == "ATHENA.MIT.EDU": if realm.upper() == "ATHENA.MIT.EDU":
# Hack to make ctl's fake username setup work :) # Hack to make ctl's fake username setup work :)
if user.lower() == "golem": if user.lower() == "golem":
@ -65,7 +65,7 @@ def to_zulip_username(zephyr_username: str) -> str:
def to_zephyr_username(zulip_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: if "|" not in user:
# Hack to make ctl's fake username setup work :) # Hack to make ctl's fake username setup work :)
if user.lower() == "ctl": 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]: def parse_zephyr_body(zephyr_data: str, notice_format: str) -> Tuple[str, str]:
try: try:
(zsig, body) = zephyr_data.split("\x00", 1) zsig, body = zephyr_data.split("\x00", 1)
if notice_format in ( if notice_format in (
"New transaction [$1] entered in $2\nFrom: $3 ($5)\nSubject: $4", "New transaction [$1] entered in $2\nFrom: $3 ($5)\nSubject: $4",
"New transaction [$1] entered in $2\nFrom: $3\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], fields[3],
) )
except ValueError: except ValueError:
(zsig, body) = ("", zephyr_data) zsig, body = "", zephyr_data
# Clean body of any null characters, since they're invalid in our protocol. # Clean body of any null characters, since they're invalid in our protocol.
body = body.replace("\x00", "") body = body.replace("\x00", "")
return (zsig, body) return (zsig, body)
@ -448,7 +448,7 @@ def process_notice(
notice: zephyr_ctypes.ZNotice_t, zulip_queue: "Queue[ZephyrDict]", log: Optional[IO[str]] notice: zephyr_ctypes.ZNotice_t, zulip_queue: "Queue[ZephyrDict]", log: Optional[IO[str]]
) -> None: ) -> None:
assert notice.z_sender is not 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_message[: notice.z_message_len].decode(errors="replace"),
notice.z_default_format.decode(errors="replace"), notice.z_default_format.decode(errors="replace"),
) )
@ -852,7 +852,7 @@ Zulip users (like you) received it, Zephyr users did not.
logger.debug("Would have forwarded: %r\n%s", zwrite_args, wrapped_content) logger.debug("Would have forwarded: %r\n%s", zwrite_args, wrapped_content)
return return
(code, stderr) = send_authed_zephyr(zwrite_args, wrapped_content) code, stderr = send_authed_zephyr(zwrite_args, wrapped_content)
if code == 0 and stderr == "": if code == 0 and stderr == "":
return return
elif code == 0: elif code == 0:
@ -876,7 +876,7 @@ returned the following warning:
): ):
# Retry sending the message unauthenticated; if that works, # Retry sending the message unauthenticated; if that works,
# just notify the user that they need to renew their tickets # 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 code == 0:
if options.ignore_expired_tickets: if options.ignore_expired_tickets:
return return
@ -1106,7 +1106,7 @@ def parse_zephyr_subs(verbose: bool = False) -> Set[Tuple[str, str, str]]:
if len(line) == 0: if len(line) == 0:
continue continue
try: try:
(cls, instance, recipient) = line.split(",") cls, instance, recipient = line.split(",")
cls = cls.replace("%me%", options.user) cls = cls.replace("%me%", options.user)
instance = instance.replace("%me%", options.user) instance = instance.replace("%me%", options.user)
recipient = recipient.replace("%me%", options.user) recipient = recipient.replace("%me%", options.user)
@ -1252,7 +1252,7 @@ if __name__ == "__main__":
signal.signal(signal.SIGINT, die_gracefully) signal.signal(signal.SIGINT, die_gracefully)
(options, args) = parse_args() options, args = parse_args()
logger = open_logger() logger = open_logger()
configure_logger(logger, "parent") configure_logger(logger, "parent")

View file

@ -743,7 +743,7 @@ class Client:
# making a new long-polling request. # making a new long-polling request.
while True: while True:
if queue_id is None: if queue_id is None:
(queue_id, last_event_id) = do_register() queue_id, last_event_id = do_register()
try: try:
res = self.get_events(queue_id=queue_id, last_event_id=last_event_id) res = self.get_events(queue_id=queue_id, last_event_id=last_event_id)

View file

@ -93,7 +93,7 @@ def get_translate_bot_response(message_content, config_file, author, all_languag
split_text.append("") split_text.append("")
if len(split_text) != 3: if len(split_text) != 3:
return help_text 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:] text_to_translate = text_to_translate[1:]
target_language = get_code_for_language(target_language, all_languages) target_language = get_code_for_language(target_language, all_languages)
if target_language == "": if target_language == "":

View file

@ -34,7 +34,7 @@ class IncidentHandler:
start_new_incident(query, message, bot_handler) start_new_incident(query, message, bot_handler)
elif query.startswith("answer "): elif query.startswith("answer "):
try: try:
(ticket_id, answer) = parse_answer(query) ticket_id, answer = parse_answer(query)
except InvalidAnswerError: except InvalidAnswerError:
bot_response = "Invalid answer format" bot_response = "Invalid answer format"
bot_handler.send_reply(message, bot_response) bot_handler.send_reply(message, bot_response)

View file

@ -35,7 +35,7 @@ class TriviaQuizHandler:
return return
elif query.startswith("answer"): elif query.startswith("answer"):
try: try:
(quiz_id, answer) = parse_answer(query) quiz_id, answer = parse_answer(query)
except InvalidAnswerError: except InvalidAnswerError:
bot_response = "Invalid answer format" bot_response = "Invalid answer format"
bot_handler.send_reply(message, bot_response) bot_handler.send_reply(message, bot_response)