Skip to content

Commit 5b5fda2

Browse files
committed
Fix % formatting without a tuple.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent edcb894 commit 5b5fda2

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

zulip/integrations/bridge_with_irc/irc_mirror_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def forward_to_irc(msg: Dict[str, Any]) -> None:
6464
in_the_specified_stream = msg["display_recipient"] == self.stream
6565
at_the_specified_subject = msg["subject"].casefold() == self.topic.casefold()
6666
if in_the_specified_stream and at_the_specified_subject:
67-
msg["content"] = ("@**%s**: " % msg["sender_full_name"]) + msg["content"]
67+
msg["content"] = ("@**%s**: " % (msg["sender_full_name"],)) + msg["content"]
6868
send = lambda x: self.c.privmsg(self.channel, x)
6969
else:
7070
return

zulip/integrations/bridge_with_matrix/matrix_bridge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _matrix_to_zulip(room: Any, event: Dict[str, Any]) -> None:
7272
"""
7373
content = get_message_content_from_event(event, no_noise)
7474

75-
zulip_bot_user = ('@%s:matrix.org' % matrix_config['username'])
75+
zulip_bot_user = '@%s:matrix.org' % (matrix_config['username'],)
7676
# We do this to identify the messages generated from Zulip -> Matrix
7777
# and we make sure we don't forward it again to the Zulip stream.
7878
not_from_zulip_bot = event['sender'] != zulip_bot_user

zulip/integrations/codebase/zulip_codebase_mirror

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def handle_event(event: Dict[str, Any]) -> None:
231231
"subject": subject,
232232
"content": content})
233233
if res['result'] == 'success':
234-
logging.info("Successfully sent Zulip with id: %s" % (res['id']))
234+
logging.info("Successfully sent Zulip with id: %s" % (res['id'],))
235235
else:
236236
logging.warn("Failed to send Zulip: %s %s" % (res['result'], res['msg']))
237237

@@ -251,7 +251,7 @@ def run_mirror() -> None:
251251
else:
252252
since = datetime.fromtimestamp(float(timestamp), tz=pytz.utc)
253253
except (ValueError, OSError) as e:
254-
logging.warn("Could not open resume file: %s" % (str(e)))
254+
logging.warn("Could not open resume file: %s" % (str(e),))
255255
since = default_since()
256256

257257
try:

zulip/integrations/trac/zulip_trac.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ def ticket_changed(self, ticket: Any, comment: str, author: str, old_values: Dic
103103

104104
def ticket_deleted(self, ticket: Any) -> None:
105105
"""Called when a ticket is deleted."""
106-
content = "%s was deleted." % markdown_ticket_url(ticket, heading="Ticket")
106+
content = "%s was deleted." % (markdown_ticket_url(ticket, heading="Ticket"),)
107107
send_update(ticket, content)

zulip/zulip/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ def end_error_retry(succeeded: bool) -> None:
565565
continue
566566
else:
567567
end_error_retry(False)
568-
return {'msg': "Connection error:\n%s" % traceback.format_exc(),
568+
return {'msg': "Connection error:\n%s" % (traceback.format_exc(),),
569569
"result": "connection-error"}
570570
except requests.exceptions.ConnectionError:
571571
if not self.has_connected:
@@ -578,11 +578,11 @@ def end_error_retry(succeeded: bool) -> None:
578578
if error_retry(""):
579579
continue
580580
end_error_retry(False)
581-
return {'msg': "Connection error:\n%s" % traceback.format_exc(),
581+
return {'msg': "Connection error:\n%s" % (traceback.format_exc(),),
582582
"result": "connection-error"}
583583
except Exception:
584584
# We'll split this out into more cases as we encounter new bugs.
585-
return {'msg': "Unexpected error:\n%s" % traceback.format_exc(),
585+
return {'msg': "Unexpected error:\n%s" % (traceback.format_exc(),),
586586
"result": "unexpected-error"}
587587

588588
try:
@@ -630,7 +630,7 @@ def do_register() -> Tuple[str, int]:
630630

631631
if 'error' in res['result']:
632632
if self.verbose:
633-
print("Server returned error:\n%s" % res['msg'])
633+
print("Server returned error:\n%s" % (res['msg'],))
634634
time.sleep(1)
635635
else:
636636
return (res['queue_id'], res['last_event_id'])
@@ -653,7 +653,7 @@ def do_register() -> Tuple[str, int]:
653653
print("Connection error fetching events -- probably server is temporarily down?")
654654
else:
655655
if self.verbose:
656-
print("Server returned error:\n%s" % res["msg"])
656+
print("Server returned error:\n%s" % (res["msg"],))
657657
# Eventually, we'll only want the
658658
# BAD_EVENT_QUEUE_ID check, but we check for the
659659
# old string to support legacy Zulip servers. We

zulip/zulip/send.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def do_send_message(client: zulip.Client, message_data: Dict[str, Any]) -> bool:
2020
log.info('Sending message to stream "%s", subject "%s"... ' %
2121
(message_data['to'], message_data['subject']))
2222
else:
23-
log.info('Sending message to %s... ' % message_data['to'])
23+
log.info('Sending message to %s... ' % (message_data['to'],))
2424
response = client.send_message(message_data)
2525
if response['result'] == 'success':
2626
log.info('Message sent.')

zulip_bots/zulip_bots/bots/giphy/giphy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ def get_bot_giphy_response(message: Dict[str, str], bot_handler: BotHandler, con
9494
'let\'s try again later! :grin:')
9595
except GiphyNoResultException:
9696
return ('Sorry, I don\'t have a GIF for "%s"! '
97-
':astonished:' % (keyword))
97+
':astonished:' % (keyword,))
9898
return ('[Click to enlarge](%s)'
9999
'[](/static/images/interactive-bot/giphy/powered-by-giphy.png)'
100-
% (gif_url))
100+
% (gif_url,))
101101

102102
handler_class = GiphyHandler

zulip_bots/zulip_bots/bots/xkcd/xkcd.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,21 @@ def get_xkcd_bot_response(message: Dict[str, str], quoted_name: str) -> str:
6464

6565
try:
6666
if command == 'help':
67-
return commands_help % ('xkcd bot supports these commands:')
67+
return commands_help % ('xkcd bot supports these commands:',)
6868
elif command == 'latest':
6969
fetched = fetch_xkcd_query(XkcdBotCommand.LATEST)
7070
elif command == 'random':
7171
fetched = fetch_xkcd_query(XkcdBotCommand.RANDOM)
7272
elif command.isdigit():
7373
fetched = fetch_xkcd_query(XkcdBotCommand.COMIC_ID, command)
7474
else:
75-
return commands_help % ("xkcd bot only supports these commands, not `%s`:" % (command,))
75+
return commands_help % ("xkcd bot only supports these commands, not `%s`:" % (command,),)
7676
except (requests.exceptions.ConnectionError, XkcdServerError):
7777
logging.exception('Connection error occurred when trying to connect to xkcd server')
7878
return 'Sorry, I cannot process your request right now, please try again later!'
7979
except XkcdNotFoundError:
8080
logging.exception('XKCD server responded 404 when trying to fetch comic with id %s'
81-
% (command))
81+
% (command,))
8282
return 'Sorry, there is likely no xkcd comic strip with id: #%s' % (command,)
8383
else:
8484
return ("#%s: **%s**\n[%s](%s)" % (fetched['num'],
@@ -99,12 +99,12 @@ def fetch_xkcd_query(mode: int, comic_id: Optional[str] = None) -> Dict[str, str
9999

100100
latest_id = latest.json()['num']
101101
random_id = random.randint(1, latest_id)
102-
url = XKCD_TEMPLATE_URL % (str(random_id))
102+
url = XKCD_TEMPLATE_URL % (str(random_id),)
103103

104104
elif mode == XkcdBotCommand.COMIC_ID: # Fetch specific comic strip by id number.
105105
if comic_id is None:
106106
raise Exception('Missing comic_id argument')
107-
url = XKCD_TEMPLATE_URL % (comic_id)
107+
url = XKCD_TEMPLATE_URL % (comic_id,)
108108

109109
fetched = requests.get(url)
110110

0 commit comments

Comments
 (0)