Skip to content

Commit e537bbe

Browse files
committed
ruff: Fix G001 Logging statement uses str.format.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 1ccb5db commit e537bbe

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
lines changed

zulip/integrations/codebase/zulip_codebase_mirror

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ def handle_event(event: Dict[str, Any]) -> None:
262262
{"type": "stream", "to": stream, "subject": subject, "content": content}
263263
)
264264
if res["result"] == "success":
265-
logging.info("Successfully sent Zulip with id: {}".format(res["id"]))
265+
logging.info("Successfully sent Zulip with id: %s", res["id"])
266266
else:
267-
logging.warning("Failed to send Zulip: {} {}".format(res["result"], res["msg"]))
267+
logging.warning("Failed to send Zulip: %s %s", res["result"], res["msg"])
268268

269269

270270
# the main run loop for this mirror script

zulip/integrations/zephyr/zephyr_mirror_backend.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,9 @@ def zephyr_to_zulip(options: optparse.Values) -> None:
669669
if "instance" in zeph:
670670
zeph["subject"] = zeph["instance"]
671671
logger.info(
672-
"sending saved message to {} from {}...".format(
673-
zeph.get("stream", zeph.get("recipient")), zeph["sender"]
674-
)
672+
"sending saved message to %s from %s...",
673+
zeph.get("stream", zeph.get("recipient")),
674+
zeph["sender"],
675675
)
676676
send_zulip(zulip_client, zeph)
677677
except Exception:
@@ -711,9 +711,7 @@ def send_zephyr(zwrite_args: List[str], content: str) -> Tuple[int, str]:
711711
if stdout:
712712
logger.info("stdout: " + stdout)
713713
elif stderr:
714-
logger.warning(
715-
"zwrite command '{}' printed the following warning:".format(" ".join(zwrite_args))
716-
)
714+
logger.warning("zwrite command %r printed the following warning:", zwrite_args)
717715
if stderr:
718716
logger.warning("stderr: " + stderr)
719717
return (p.returncode, stderr)
@@ -929,7 +927,7 @@ def maybe_forward_to_zephyr(message: Dict[str, Any], zulip_client: zulip.Client)
929927
timestamp_now = int(time.time())
930928
if float(message["timestamp"]) < timestamp_now - 15:
931929
logger.warning(
932-
"Skipping out of order message: {} < {}".format(message["timestamp"], timestamp_now)
930+
"Skipping out of order message: %s < %s", message["timestamp"], timestamp_now
933931
)
934932
return
935933
try:
@@ -1018,21 +1016,17 @@ def add_zulip_subscriptions(verbose: bool) -> None:
10181016
authorization_errors_fatal=False,
10191017
)
10201018
if res.get("result") != "success":
1021-
logger.error("Error subscribing to streams:\n{}".format(res["msg"]))
1019+
logger.error("Error subscribing to streams:\n%s", res["msg"])
10221020
return
10231021

10241022
already = res.get("already_subscribed")
10251023
new = res.get("subscribed")
10261024
unauthorized = res.get("unauthorized")
10271025
if verbose:
10281026
if already is not None and len(already) > 0:
1029-
logger.info(
1030-
"\nAlready subscribed to: {}".format(", ".join(list(already.values())[0]))
1031-
)
1027+
logger.info("\nAlready subscribed to: %s", ", ".join(list(already.values())[0]))
10321028
if new is not None and len(new) > 0:
1033-
logger.info(
1034-
"\nSuccessfully subscribed to: {}".format(", ".join(list(new.values())[0]))
1035-
)
1029+
logger.info("\nSuccessfully subscribed to: %s", ", ".join(list(new.values())[0]))
10361030
if unauthorized is not None and len(unauthorized) > 0:
10371031
logger.info(
10381032
"\n"

zulip/zulip/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def send_message(recipients: List[str], stream: str, subject: str, message: str)
8484

8585
if message_data["type"] == "stream":
8686
log.info(
87-
'Sending message to stream "{}", subject "{}"... '.format(
88-
message_data["to"], message_data["subject"]
89-
)
87+
"Sending message to stream %r, subject %r... ",
88+
message_data["to"],
89+
message_data["subject"],
9090
)
9191
else:
9292
log.info("Sending message to %s... " % message_data["to"])

zulip/zulip/send.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ def do_send_message(client: zulip.Client, message_data: Dict[str, Any]) -> bool:
1818

1919
if message_data["type"] == "stream":
2020
log.info(
21-
'Sending message to stream "{}", subject "{}"... '.format(
22-
message_data["to"], message_data["subject"]
23-
)
21+
"Sending message to stream %r, subject %r... ",
22+
message_data["to"],
23+
message_data["subject"],
2424
)
2525
else:
26-
log.info("Sending message to {}... ".format(message_data["to"]))
26+
log.info("Sending message to %s... ", message_data["to"])
2727
response = client.send_message(message_data)
2828
if response["result"] == "success":
2929
log.info("Message sent.")

zulip_botserver/zulip_botserver/server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ def read_config_from_env_vars(bot_name: Optional[str] = None) -> Dict[str, Dict[
5353
first_bot_name = list(env_config.keys())[0]
5454
bots_config[bot_name] = env_config[first_bot_name]
5555
logging.warning(
56-
"First bot name in the config list was changed from '{}' to '{}'".format(
57-
first_bot_name, bot_name
58-
)
56+
"First bot name in the config list was changed from %r to %r",
57+
first_bot_name,
58+
bot_name,
5959
)
6060
else:
6161
bots_config = dict(env_config)

0 commit comments

Comments
 (0)