ruff: Fix G001 Logging statement uses str.format
.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
1ccb5db6ef
commit
e537bbefdf
5 changed files with 20 additions and 26 deletions
|
@ -262,9 +262,9 @@ def handle_event(event: Dict[str, Any]) -> None:
|
||||||
{"type": "stream", "to": stream, "subject": subject, "content": content}
|
{"type": "stream", "to": stream, "subject": subject, "content": content}
|
||||||
)
|
)
|
||||||
if res["result"] == "success":
|
if res["result"] == "success":
|
||||||
logging.info("Successfully sent Zulip with id: {}".format(res["id"]))
|
logging.info("Successfully sent Zulip with id: %s", res["id"])
|
||||||
else:
|
else:
|
||||||
logging.warning("Failed to send Zulip: {} {}".format(res["result"], res["msg"]))
|
logging.warning("Failed to send Zulip: %s %s", res["result"], res["msg"])
|
||||||
|
|
||||||
|
|
||||||
# the main run loop for this mirror script
|
# the main run loop for this mirror script
|
||||||
|
|
|
@ -669,9 +669,9 @@ def zephyr_to_zulip(options: optparse.Values) -> None:
|
||||||
if "instance" in zeph:
|
if "instance" in zeph:
|
||||||
zeph["subject"] = zeph["instance"]
|
zeph["subject"] = zeph["instance"]
|
||||||
logger.info(
|
logger.info(
|
||||||
"sending saved message to {} from {}...".format(
|
"sending saved message to %s from %s...",
|
||||||
zeph.get("stream", zeph.get("recipient")), zeph["sender"]
|
zeph.get("stream", zeph.get("recipient")),
|
||||||
)
|
zeph["sender"],
|
||||||
)
|
)
|
||||||
send_zulip(zulip_client, zeph)
|
send_zulip(zulip_client, zeph)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -711,9 +711,7 @@ def send_zephyr(zwrite_args: List[str], content: str) -> Tuple[int, str]:
|
||||||
if stdout:
|
if stdout:
|
||||||
logger.info("stdout: " + stdout)
|
logger.info("stdout: " + stdout)
|
||||||
elif stderr:
|
elif stderr:
|
||||||
logger.warning(
|
logger.warning("zwrite command %r printed the following warning:", zwrite_args)
|
||||||
"zwrite command '{}' printed the following warning:".format(" ".join(zwrite_args))
|
|
||||||
)
|
|
||||||
if stderr:
|
if stderr:
|
||||||
logger.warning("stderr: " + stderr)
|
logger.warning("stderr: " + stderr)
|
||||||
return (p.returncode, stderr)
|
return (p.returncode, stderr)
|
||||||
|
@ -929,7 +927,7 @@ def maybe_forward_to_zephyr(message: Dict[str, Any], zulip_client: zulip.Client)
|
||||||
timestamp_now = int(time.time())
|
timestamp_now = int(time.time())
|
||||||
if float(message["timestamp"]) < timestamp_now - 15:
|
if float(message["timestamp"]) < timestamp_now - 15:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Skipping out of order message: {} < {}".format(message["timestamp"], timestamp_now)
|
"Skipping out of order message: %s < %s", message["timestamp"], timestamp_now
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
@ -1018,7 +1016,7 @@ def add_zulip_subscriptions(verbose: bool) -> None:
|
||||||
authorization_errors_fatal=False,
|
authorization_errors_fatal=False,
|
||||||
)
|
)
|
||||||
if res.get("result") != "success":
|
if res.get("result") != "success":
|
||||||
logger.error("Error subscribing to streams:\n{}".format(res["msg"]))
|
logger.error("Error subscribing to streams:\n%s", res["msg"])
|
||||||
return
|
return
|
||||||
|
|
||||||
already = res.get("already_subscribed")
|
already = res.get("already_subscribed")
|
||||||
|
@ -1026,13 +1024,9 @@ def add_zulip_subscriptions(verbose: bool) -> None:
|
||||||
unauthorized = res.get("unauthorized")
|
unauthorized = res.get("unauthorized")
|
||||||
if verbose:
|
if verbose:
|
||||||
if already is not None and len(already) > 0:
|
if already is not None and len(already) > 0:
|
||||||
logger.info(
|
logger.info("\nAlready subscribed to: %s", ", ".join(list(already.values())[0]))
|
||||||
"\nAlready subscribed to: {}".format(", ".join(list(already.values())[0]))
|
|
||||||
)
|
|
||||||
if new is not None and len(new) > 0:
|
if new is not None and len(new) > 0:
|
||||||
logger.info(
|
logger.info("\nSuccessfully subscribed to: %s", ", ".join(list(new.values())[0]))
|
||||||
"\nSuccessfully subscribed to: {}".format(", ".join(list(new.values())[0]))
|
|
||||||
)
|
|
||||||
if unauthorized is not None and len(unauthorized) > 0:
|
if unauthorized is not None and len(unauthorized) > 0:
|
||||||
logger.info(
|
logger.info(
|
||||||
"\n"
|
"\n"
|
||||||
|
|
|
@ -84,9 +84,9 @@ def send_message(recipients: List[str], stream: str, subject: str, message: str)
|
||||||
|
|
||||||
if message_data["type"] == "stream":
|
if message_data["type"] == "stream":
|
||||||
log.info(
|
log.info(
|
||||||
'Sending message to stream "{}", subject "{}"... '.format(
|
"Sending message to stream %r, subject %r... ",
|
||||||
message_data["to"], message_data["subject"]
|
message_data["to"],
|
||||||
)
|
message_data["subject"],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
log.info("Sending message to %s... " % message_data["to"])
|
log.info("Sending message to %s... " % message_data["to"])
|
||||||
|
|
|
@ -18,12 +18,12 @@ def do_send_message(client: zulip.Client, message_data: Dict[str, Any]) -> bool:
|
||||||
|
|
||||||
if message_data["type"] == "stream":
|
if message_data["type"] == "stream":
|
||||||
log.info(
|
log.info(
|
||||||
'Sending message to stream "{}", subject "{}"... '.format(
|
"Sending message to stream %r, subject %r... ",
|
||||||
message_data["to"], message_data["subject"]
|
message_data["to"],
|
||||||
)
|
message_data["subject"],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
log.info("Sending message to {}... ".format(message_data["to"]))
|
log.info("Sending message to %s... ", message_data["to"])
|
||||||
response = client.send_message(message_data)
|
response = client.send_message(message_data)
|
||||||
if response["result"] == "success":
|
if response["result"] == "success":
|
||||||
log.info("Message sent.")
|
log.info("Message sent.")
|
||||||
|
|
|
@ -53,9 +53,9 @@ def read_config_from_env_vars(bot_name: Optional[str] = None) -> Dict[str, Dict[
|
||||||
first_bot_name = list(env_config.keys())[0]
|
first_bot_name = list(env_config.keys())[0]
|
||||||
bots_config[bot_name] = env_config[first_bot_name]
|
bots_config[bot_name] = env_config[first_bot_name]
|
||||||
logging.warning(
|
logging.warning(
|
||||||
"First bot name in the config list was changed from '{}' to '{}'".format(
|
"First bot name in the config list was changed from %r to %r",
|
||||||
first_bot_name, bot_name
|
first_bot_name,
|
||||||
)
|
bot_name,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
bots_config = dict(env_config)
|
bots_config = dict(env_config)
|
||||||
|
|
Loading…
Add table
Reference in a new issue