Skip to content

Commit

Permalink
python: Fix PAR002 Dont use parentheses for unpacking.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Nov 12, 2023
1 parent 059458b commit 6aedfe6
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion zulip/integrations/jabber/jabber_mirror_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
10 changes: 5 additions & 5 deletions zulip/integrations/zephyr/check-mirroring
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]"

Expand Down Expand Up @@ -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))
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion zulip/integrations/zephyr/zephyr_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 10 additions & 10 deletions zulip/integrations/zephyr/zephyr_mirror_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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":
Expand Down Expand Up @@ -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",
Expand All @@ -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)
Expand Down Expand Up @@ -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"),
)
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion zulip/zulip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "":
Expand Down
2 changes: 1 addition & 1 deletion zulip_bots/zulip_bots/bots/incident/incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6aedfe6

Please sign in to comment.