ruff: Fix PLR5501 Use elif
instead of else
then if
, to reduce indentation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
5c934e544d
commit
11ea5c7b62
6 changed files with 33 additions and 41 deletions
|
@ -295,10 +295,9 @@ def run_mirror() -> None:
|
|||
if event_date > since:
|
||||
handle_event(event)
|
||||
since = event_date
|
||||
else:
|
||||
elif sleep_interval < 22:
|
||||
# back off a bit
|
||||
if sleep_interval < 22:
|
||||
sleep_interval += 4
|
||||
sleep_interval += 4
|
||||
time.sleep(sleep_interval)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
|
|
|
@ -258,13 +258,12 @@ def get_phase_number(grid, turn, x_pieces_possessed_not_on_grid, o_pieces_posses
|
|||
if x_pieces_possessed_not_on_grid != 0 or o_pieces_possessed_not_on_grid != 0:
|
||||
# Placing pieces
|
||||
return 1
|
||||
elif get_piece("X", grid) <= 3 or get_piece("O", grid) <= 3:
|
||||
# Flying
|
||||
return 3
|
||||
else:
|
||||
if get_piece("X", grid) <= 3 or get_piece("O", grid) <= 3:
|
||||
# Flying
|
||||
return 3
|
||||
else:
|
||||
# Moving pieces
|
||||
return 2
|
||||
# Moving pieces
|
||||
return 2
|
||||
|
||||
|
||||
def create_room(topic_name, merels_storage):
|
||||
|
|
|
@ -60,15 +60,14 @@ class TrelloHandler:
|
|||
bot_reply = self.get_all_supported_commands()
|
||||
elif content == ["get-all-boards"]:
|
||||
bot_reply = self.get_all_boards()
|
||||
elif content[0] == "get-all-cards":
|
||||
bot_reply = self.get_all_cards(content)
|
||||
elif content[0] == "get-all-checklists":
|
||||
bot_reply = self.get_all_checklists(content)
|
||||
elif content[0] == "get-all-lists":
|
||||
bot_reply = self.get_all_lists(content)
|
||||
else:
|
||||
if content[0] == "get-all-cards":
|
||||
bot_reply = self.get_all_cards(content)
|
||||
elif content[0] == "get-all-checklists":
|
||||
bot_reply = self.get_all_checklists(content)
|
||||
elif content[0] == "get-all-lists":
|
||||
bot_reply = self.get_all_lists(content)
|
||||
else:
|
||||
bot_reply = "Command not supported"
|
||||
bot_reply = "Command not supported"
|
||||
|
||||
bot_handler.send_reply(message, bot_reply)
|
||||
|
||||
|
|
|
@ -207,11 +207,10 @@ def update_quiz(quiz: Dict[str, Any], quiz_id: str, bot_handler: BotHandler) ->
|
|||
def build_response(is_correct: bool, num_answers: int) -> str:
|
||||
if is_correct:
|
||||
response = ":tada: **{answer}** is correct, {sender_name}!"
|
||||
elif num_answers >= 3:
|
||||
response = ":disappointed: WRONG, {sender_name}! The correct answer is **{answer}**."
|
||||
else:
|
||||
if num_answers >= 3:
|
||||
response = ":disappointed: WRONG, {sender_name}! The correct answer is **{answer}**."
|
||||
else:
|
||||
response = ":disappointed: WRONG, {sender_name}! {option} is not correct."
|
||||
response = ":disappointed: WRONG, {sender_name}! {option} is not correct."
|
||||
return response
|
||||
|
||||
|
||||
|
|
|
@ -290,11 +290,10 @@ class GameAdapter:
|
|||
self.send_reply(
|
||||
message, "You are not in a game at the moment. Type `help` for help."
|
||||
)
|
||||
elif self.is_single_player:
|
||||
self.send_reply(message, self.help_message_single_player())
|
||||
else:
|
||||
if self.is_single_player:
|
||||
self.send_reply(message, self.help_message_single_player())
|
||||
else:
|
||||
self.send_reply(message, self.help_message())
|
||||
self.send_reply(message, self.help_message())
|
||||
except Exception as e:
|
||||
logging.exception("Error handling game message")
|
||||
self.bot_handler.send_reply(message, f"Error {e}.")
|
||||
|
@ -893,16 +892,15 @@ class GameInstance:
|
|||
return
|
||||
if self.is_turn_of(player_email):
|
||||
self.handle_current_player_command(content)
|
||||
elif self.game_adapter.is_single_player:
|
||||
self.broadcast("It's your turn")
|
||||
else:
|
||||
if self.game_adapter.is_single_player:
|
||||
self.broadcast("It's your turn")
|
||||
else:
|
||||
self.broadcast(
|
||||
"It's **{}**'s ({}) turn.".format(
|
||||
self.game_adapter.get_username_by_email(self.players[self.turn]),
|
||||
self.game_adapter.game_message_handler.get_player_color(self.turn),
|
||||
)
|
||||
self.broadcast(
|
||||
"It's **{}**'s ({}) turn.".format(
|
||||
self.game_adapter.get_username_by_email(self.players[self.turn]),
|
||||
self.game_adapter.game_message_handler.get_player_color(self.turn),
|
||||
)
|
||||
)
|
||||
|
||||
def broadcast(self, content: str) -> None:
|
||||
self.game_adapter.broadcast(self.game_id, content)
|
||||
|
@ -1022,11 +1020,10 @@ class GameInstance:
|
|||
values.update({"games_drawn": 1})
|
||||
else:
|
||||
values.update({"games_lost": 1})
|
||||
elif u == loser:
|
||||
values.update({"games_lost": 1})
|
||||
else:
|
||||
if u == loser:
|
||||
values.update({"games_lost": 1})
|
||||
else:
|
||||
values.update({"games_won": 1})
|
||||
values.update({"games_won": 1})
|
||||
self.game_adapter.add_user_statistics(u, values)
|
||||
if self.game_adapter.email in self.players:
|
||||
self.send_win_responses(winner)
|
||||
|
|
|
@ -72,11 +72,10 @@ def exit_gracefully_if_zulip_config_is_missing(config_file: Optional[str]) -> No
|
|||
else:
|
||||
error_msg = f"ERROR: {config_file} does not exist."
|
||||
|
||||
elif zulip_env_vars_are_present():
|
||||
return
|
||||
else:
|
||||
if zulip_env_vars_are_present():
|
||||
return
|
||||
else:
|
||||
error_msg = "ERROR: You did not supply a Zulip config file."
|
||||
error_msg = "ERROR: You did not supply a Zulip config file."
|
||||
|
||||
if error_msg:
|
||||
print("\n")
|
||||
|
|
Loading…
Add table
Reference in a new issue