From 32e052019668bc9355b8fad517075dac6ffbe8d4 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 30 Oct 2023 11:03:34 -0700 Subject: [PATCH] ruff: Fix B005 Using `.strip()` with multi-character strings is misleading. Signed-off-by: Anders Kaseorg --- zulip_bots/zulip_bots/game_handler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zulip_bots/zulip_bots/game_handler.py b/zulip_bots/zulip_bots/game_handler.py index 76fe9f45..65db230b 100644 --- a/zulip_bots/zulip_bots/game_handler.py +++ b/zulip_bots/zulip_bots/game_handler.py @@ -693,7 +693,11 @@ To move subjects, send your message again, otherwise join the game using the lin verified_users = [] failed = False for u in users: - user = u.strip().lstrip("@**").rstrip("**") + user = u.strip() + if user.startswith("@**"): + user = user[len("@**") :] + if user.endswith("**"): + user = user[: -len("**")] if ( user == self.get_bot_username() or user == self.email ) and not self.supports_computer: @@ -1007,7 +1011,7 @@ class GameInstance: if winner == "draw": self.broadcast("It was a draw!") elif winner.startswith("except:"): - loser = winner.lstrip("except:") + loser = winner[len("except:") :] else: winner_name = self.game_adapter.get_username_by_email(winner) self.broadcast(f"**{winner_name}** won! :tada:")