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:
Anders Kaseorg 2023-10-30 10:46:17 -07:00
parent 5c934e544d
commit 11ea5c7b62
6 changed files with 33 additions and 41 deletions

View file

@ -295,9 +295,8 @@ def run_mirror() -> None:
if event_date > since: if event_date > since:
handle_event(event) handle_event(event)
since = event_date since = event_date
else: elif sleep_interval < 22:
# back off a bit # back off a bit
if sleep_interval < 22:
sleep_interval += 4 sleep_interval += 4
time.sleep(sleep_interval) time.sleep(sleep_interval)

View file

@ -258,8 +258,7 @@ 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: if x_pieces_possessed_not_on_grid != 0 or o_pieces_possessed_not_on_grid != 0:
# Placing pieces # Placing pieces
return 1 return 1
else: elif get_piece("X", grid) <= 3 or get_piece("O", grid) <= 3:
if get_piece("X", grid) <= 3 or get_piece("O", grid) <= 3:
# Flying # Flying
return 3 return 3
else: else:

View file

@ -60,8 +60,7 @@ class TrelloHandler:
bot_reply = self.get_all_supported_commands() bot_reply = self.get_all_supported_commands()
elif content == ["get-all-boards"]: elif content == ["get-all-boards"]:
bot_reply = self.get_all_boards() bot_reply = self.get_all_boards()
else: elif content[0] == "get-all-cards":
if content[0] == "get-all-cards":
bot_reply = self.get_all_cards(content) bot_reply = self.get_all_cards(content)
elif content[0] == "get-all-checklists": elif content[0] == "get-all-checklists":
bot_reply = self.get_all_checklists(content) bot_reply = self.get_all_checklists(content)

View file

@ -207,8 +207,7 @@ def update_quiz(quiz: Dict[str, Any], quiz_id: str, bot_handler: BotHandler) ->
def build_response(is_correct: bool, num_answers: int) -> str: def build_response(is_correct: bool, num_answers: int) -> str:
if is_correct: if is_correct:
response = ":tada: **{answer}** is correct, {sender_name}!" response = ":tada: **{answer}** is correct, {sender_name}!"
else: elif num_answers >= 3:
if num_answers >= 3:
response = ":disappointed: WRONG, {sender_name}! The correct answer is **{answer}**." response = ":disappointed: WRONG, {sender_name}! The correct answer is **{answer}**."
else: else:
response = ":disappointed: WRONG, {sender_name}! {option} is not correct." response = ":disappointed: WRONG, {sender_name}! {option} is not correct."

View file

@ -290,8 +290,7 @@ class GameAdapter:
self.send_reply( self.send_reply(
message, "You are not in a game at the moment. Type `help` for help." message, "You are not in a game at the moment. Type `help` for help."
) )
else: elif self.is_single_player:
if self.is_single_player:
self.send_reply(message, self.help_message_single_player()) self.send_reply(message, self.help_message_single_player())
else: else:
self.send_reply(message, self.help_message()) self.send_reply(message, self.help_message())
@ -893,8 +892,7 @@ class GameInstance:
return return
if self.is_turn_of(player_email): if self.is_turn_of(player_email):
self.handle_current_player_command(content) self.handle_current_player_command(content)
else: elif self.game_adapter.is_single_player:
if self.game_adapter.is_single_player:
self.broadcast("It's your turn") self.broadcast("It's your turn")
else: else:
self.broadcast( self.broadcast(
@ -1022,8 +1020,7 @@ class GameInstance:
values.update({"games_drawn": 1}) values.update({"games_drawn": 1})
else: else:
values.update({"games_lost": 1}) values.update({"games_lost": 1})
else: elif u == loser:
if u == loser:
values.update({"games_lost": 1}) values.update({"games_lost": 1})
else: else:
values.update({"games_won": 1}) values.update({"games_won": 1})

View file

@ -72,8 +72,7 @@ def exit_gracefully_if_zulip_config_is_missing(config_file: Optional[str]) -> No
else: else:
error_msg = f"ERROR: {config_file} does not exist." error_msg = f"ERROR: {config_file} does not exist."
else: elif zulip_env_vars_are_present():
if zulip_env_vars_are_present():
return return
else: else:
error_msg = "ERROR: You did not supply a Zulip config file." error_msg = "ERROR: You did not supply a Zulip config file."