Skip to content

Commit d85ace8

Browse files
committed
ruff: Fix G003 Logging statement uses +.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 02e0555 commit d85ace8

File tree

3 files changed

+25
-29
lines changed

3 files changed

+25
-29
lines changed

zulip/integrations/jabber/jabber_mirror_backend.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ def session_start(self, event: Dict[str, Any]) -> None:
109109
def join_muc(self, room: str) -> None:
110110
if room in self.rooms:
111111
return
112-
logging.debug("Joining " + room)
112+
logging.debug("Joining %s", room)
113113
self.rooms.add(room)
114114
muc_jid = JID(local=room, domain=options.conference_domain)
115115
xep0045 = self.plugin["xep_0045"]
116116
try:
117117
xep0045.joinMUC(muc_jid, self.nick, wait=True)
118118
except InvalidJID:
119-
logging.error("Could not join room: " + str(muc_jid))
119+
logging.error("Could not join room: %s", muc_jid)
120120
return
121121

122122
# Configure the room. Really, we should only do this if the room is
@@ -129,12 +129,12 @@ def join_muc(self, room: str) -> None:
129129
if form:
130130
xep0045.configureRoom(muc_jid, form)
131131
else:
132-
logging.error("Could not configure room: " + str(muc_jid))
132+
logging.error("Could not configure room: %s", muc_jid)
133133

134134
def leave_muc(self, room: str) -> None:
135135
if room not in self.rooms:
136136
return
137-
logging.debug("Leaving " + room)
137+
logging.debug("Leaving %s", room)
138138
self.rooms.remove(room)
139139
muc_jid = JID(local=room, domain=options.conference_domain)
140140
self.plugin["xep_0045"].leaveMUC(muc_jid, self.nick)

zulip/integrations/zephyr/zephyr_mirror_backend.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,11 @@ def send_zephyr(zwrite_args: List[str], content: str) -> Tuple[int, str]:
707707
p.returncode,
708708
)
709709
if stdout:
710-
logger.info("stdout: " + stdout)
710+
logger.info("stdout: %s", stdout)
711711
elif stderr:
712712
logger.warning("zwrite command %r printed the following warning:", zwrite_args)
713713
if stderr:
714-
logger.warning("stderr: " + stderr)
714+
logger.warning("stderr: %s", stderr)
715715
return (p.returncode, stderr)
716716

717717

@@ -1027,10 +1027,9 @@ def add_zulip_subscriptions(verbose: bool) -> None:
10271027
logger.info("\nSuccessfully subscribed to: %s", ", ".join(list(new.values())[0]))
10281028
if unauthorized is not None and len(unauthorized) > 0:
10291029
logger.info(
1030-
"\n"
1031-
+ "\n".join(
1032-
textwrap.wrap(
1033-
"""\
1030+
"\n%s\n\n %s",
1031+
textwrap.wrap(
1032+
"""\
10341033
The following streams you have NOT been subscribed to,
10351034
because they have been configured in Zulip as invitation-only streams.
10361035
This was done at the request of users of these Zephyr classes, usually
@@ -1040,16 +1039,15 @@ def add_zulip_subscriptions(verbose: bool) -> None:
10401039
on these streams and already use Zulip. They can subscribe you to them via the
10411040
"streams" page in the Zulip web interface:
10421041
"""
1043-
)
1044-
)
1045-
+ "\n\n {}".format(", ".join(unauthorized))
1042+
),
1043+
", ".join(unauthorized),
10461044
)
10471045

10481046
if len(skipped) > 0:
10491047
if verbose:
10501048
logger.info(
1051-
"\n"
1052-
+ "\n".join(
1049+
"\n%s\n",
1050+
"\n".join(
10531051
textwrap.wrap(
10541052
"""\
10551053
You have some lines in ~/.zephyr.subs that could not be
@@ -1062,8 +1060,7 @@ def add_zulip_subscriptions(verbose: bool) -> None:
10621060
Zulip subscription to these lines in ~/.zephyr.subs:
10631061
"""
10641062
)
1065-
)
1066-
+ "\n"
1063+
),
10671064
)
10681065

10691066
for cls, instance, recipient, reason in skipped:
@@ -1075,17 +1072,16 @@ def add_zulip_subscriptions(verbose: bool) -> None:
10751072
if len(skipped) > 0:
10761073
if verbose:
10771074
logger.info(
1078-
"\n"
1079-
+ "\n".join(
1075+
"\n%s\n",
1076+
"\n".join(
10801077
textwrap.wrap(
10811078
"""\
10821079
If you wish to be subscribed to any Zulip streams related
10831080
to these .zephyrs.subs lines, please do so via the Zulip
10841081
web interface.
10851082
"""
10861083
)
1087-
)
1088-
+ "\n"
1084+
),
10891085
)
10901086

10911087

@@ -1265,15 +1261,15 @@ def die_gracefully(signal: int, frame: Optional[FrameType]) -> None:
12651261
else:
12661262
if not os.path.exists(options.api_key_file):
12671263
logger.error(
1268-
"\n"
1269-
+ "\n".join(
1264+
"\n%s",
1265+
"\n".join(
12701266
textwrap.wrap(
12711267
f"""\
12721268
Could not find API key file.
12731269
You need to either place your api key file at {options.api_key_file},
12741270
or specify the --api-key-file option."""
12751271
)
1276-
)
1272+
),
12771273
)
12781274
sys.exit(1)
12791275
api_key = open(options.api_key_file).read().strip()
@@ -1282,7 +1278,7 @@ def die_gracefully(signal: int, frame: Optional[FrameType]) -> None:
12821278
os.environ["HUMBUG_API_KEY"] = api_key
12831279

12841280
if options.nagios_path is None and options.nagios_class is not None:
1285-
logger.error("\n" + "nagios_path is required with nagios_class\n")
1281+
logger.error("\nnagios_path is required with nagios_class\n")
12861282
sys.exit(1)
12871283

12881284
zulip_account_email = options.user + "@mit.edu"

zulip_bots/zulip_bots/bots/idonethis/idonethis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def make_API_request(
4848
and "error" in r.json()
4949
and r.json()["error"] == "Invalid API Authentication"
5050
):
51-
logging.error("Error authenticating, please check key " + str(r.url))
51+
logging.error("Error authenticating, please check key %s", r.url)
5252
raise AuthenticationException
5353
else:
54-
logging.error("Error make API request, code " + str(r.status_code) + ". json: " + r.json())
54+
logging.error("Error make API request, code %s. json: %s", r.status_code, r.json())
5555
raise UnspecifiedProblemException
5656

5757

@@ -242,9 +242,9 @@ def get_response(self, message: Dict[str, Any]) -> str:
242242
"Sorry, I don't understand what your trying to say. Use `@mention help` to see my help. "
243243
+ e.detail
244244
)
245-
except Exception as e: # catches UnspecifiedProblemException, and other problems
245+
except Exception: # catches UnspecifiedProblemException, and other problems
246246
reply = "Oh dear, I'm having problems processing your request right now. Perhaps you could try again later :grinning:"
247-
logging.error("Exception caught: " + str(e))
247+
logging.exception("Exception caught")
248248
return reply
249249

250250

0 commit comments

Comments
 (0)