ruff: Fix SIM102 Use a single if
statement instead of nested if
statements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
c75f5b3a09
commit
58a3026f37
5 changed files with 53 additions and 61 deletions
|
@ -489,13 +489,10 @@ def process_notice(
|
|||
# Only forward mail zephyrs if forwarding them is enabled.
|
||||
return
|
||||
|
||||
if is_personal:
|
||||
if body.startswith("CC:"):
|
||||
if is_personal and body.startswith("CC:"):
|
||||
is_huddle = True
|
||||
# Map "CC: user1 user2" => "user1@mit.edu, user2@mit.edu"
|
||||
huddle_recipients = [
|
||||
to_zulip_username(x.strip()) for x in body.split("\n")[0][4:].split()
|
||||
]
|
||||
huddle_recipients = [to_zulip_username(x.strip()) for x in body.split("\n")[0][4:].split()]
|
||||
if zephyr_sender not in huddle_recipients:
|
||||
huddle_recipients.append(to_zulip_username(zephyr_sender))
|
||||
body = body.split("\n", 1)[1]
|
||||
|
@ -1045,8 +1042,7 @@ on these streams and already use Zulip. They can subscribe you to them via the
|
|||
", ".join(unauthorized),
|
||||
)
|
||||
|
||||
if len(skipped) > 0:
|
||||
if verbose:
|
||||
if len(skipped) > 0 and verbose:
|
||||
logger.info(
|
||||
"\n%s\n",
|
||||
"\n".join(
|
||||
|
@ -1071,8 +1067,7 @@ Zulip subscription to these lines in ~/.zephyr.subs:
|
|||
logger.info(" [%s,%s,%s] (%s)", cls, instance, recipient, reason)
|
||||
else:
|
||||
logger.info(" [%s,%s,%s]", cls, instance, recipient)
|
||||
if len(skipped) > 0:
|
||||
if verbose:
|
||||
if len(skipped) > 0 and verbose:
|
||||
logger.info(
|
||||
"\n%s\n",
|
||||
"\n".join(
|
||||
|
|
|
@ -501,8 +501,7 @@ class Client:
|
|||
else: # we have a client cert
|
||||
if not os.path.isfile(client_cert):
|
||||
raise ConfigNotFoundError(f"client cert '{client_cert}' does not exist")
|
||||
if client_cert_key is not None:
|
||||
if not os.path.isfile(client_cert_key):
|
||||
if client_cert_key is not None and not os.path.isfile(client_cert_key):
|
||||
raise ConfigNotFoundError(f"client cert key '{client_cert_key}' does not exist")
|
||||
self.client_cert = client_cert
|
||||
self.client_cert_key = client_cert_key
|
||||
|
@ -652,8 +651,9 @@ class Client:
|
|||
self.has_connected = True
|
||||
|
||||
# On 50x errors, try again after a short sleep
|
||||
if str(res.status_code).startswith("5"):
|
||||
if error_retry(f" (server {res.status_code})"):
|
||||
if str(res.status_code).startswith("5") and error_retry(
|
||||
f" (server {res.status_code})"
|
||||
):
|
||||
continue
|
||||
# Otherwise fall through and process the python-requests error normally
|
||||
except (requests.exceptions.Timeout, requests.exceptions.SSLError) as e:
|
||||
|
|
|
@ -29,8 +29,10 @@ def get_bot_result(message_content: str, config: Dict[str, str], sender_id: str)
|
|||
res_json["status"]["code"], res_json["status"]["errorDetails"]
|
||||
)
|
||||
if res_json["result"]["fulfillment"]["speech"] == "":
|
||||
if "alternateResult" in res_json.keys():
|
||||
if res_json["alternateResult"]["fulfillment"]["speech"] != "":
|
||||
if (
|
||||
"alternateResult" in res_json.keys()
|
||||
and res_json["alternateResult"]["fulfillment"]["speech"] != ""
|
||||
):
|
||||
return res_json["alternateResult"]["fulfillment"]["speech"]
|
||||
return "Error. No result."
|
||||
return res_json["result"]["fulfillment"]["speech"]
|
||||
|
|
|
@ -34,12 +34,10 @@ class MerelsModel:
|
|||
merels = database.MerelsStorage(self.topic, self.storage)
|
||||
data = game_data.GameData(merels.get_game_data(self.topic))
|
||||
|
||||
if data.get_phase() > 1:
|
||||
if (mechanics.get_piece("X", data.grid()) <= 2) or (
|
||||
mechanics.get_piece("O", data.grid()) <= 2
|
||||
):
|
||||
return True
|
||||
return False
|
||||
return data.get_phase() > 1 and (
|
||||
(mechanics.get_piece("X", data.grid()) <= 2)
|
||||
or (mechanics.get_piece("O", data.grid()) <= 2)
|
||||
)
|
||||
|
||||
def make_move(self, move: str, player_number: int, computer_move: bool = False) -> Any:
|
||||
if self.storage.get(self.topic) == '["X", 0, 0, "NNNNNNNNNNNNNNNNNNNNNNNN", "", 0]':
|
||||
|
|
|
@ -603,8 +603,7 @@ class GameAdapter:
|
|||
def get_user_by_name(self, name: str) -> Dict[str, Any]:
|
||||
name = name.strip()
|
||||
for user in self.user_cache.values():
|
||||
if "full_name" in user.keys():
|
||||
if user["full_name"].lower() == name.lower():
|
||||
if "full_name" in user.keys() and user["full_name"].lower() == name.lower():
|
||||
return user
|
||||
return {}
|
||||
|
||||
|
@ -756,8 +755,7 @@ To move subjects, send your message again, otherwise join the game using the lin
|
|||
return False
|
||||
for invite in self.invites.values():
|
||||
for u in invite.keys():
|
||||
if u == "host":
|
||||
if user_email == invite["host"]:
|
||||
if u == "host" and user_email == invite["host"]:
|
||||
return False
|
||||
if u == user_email and "a" in invite[u]:
|
||||
return False
|
||||
|
@ -776,8 +774,7 @@ To move subjects, send your message again, otherwise join the game using the lin
|
|||
if private_recipients is not None:
|
||||
for user in private_recipients:
|
||||
self.send_message(user, content, True)
|
||||
if game_id in self.invites.keys():
|
||||
if self.invites[game_id]["subject"] != "###private###":
|
||||
if game_id in self.invites.keys() and self.invites[game_id]["subject"] != "###private###":
|
||||
self.send_message(
|
||||
self.invites[game_id]["stream"],
|
||||
content,
|
||||
|
|
Loading…
Add table
Reference in a new issue