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.
|
# Only forward mail zephyrs if forwarding them is enabled.
|
||||||
return
|
return
|
||||||
|
|
||||||
if is_personal:
|
if is_personal and body.startswith("CC:"):
|
||||||
if body.startswith("CC:"):
|
|
||||||
is_huddle = True
|
is_huddle = True
|
||||||
# Map "CC: user1 user2" => "user1@mit.edu, user2@mit.edu"
|
# Map "CC: user1 user2" => "user1@mit.edu, user2@mit.edu"
|
||||||
huddle_recipients = [
|
huddle_recipients = [to_zulip_username(x.strip()) for x in body.split("\n")[0][4:].split()]
|
||||||
to_zulip_username(x.strip()) for x in body.split("\n")[0][4:].split()
|
|
||||||
]
|
|
||||||
if zephyr_sender not in huddle_recipients:
|
if zephyr_sender not in huddle_recipients:
|
||||||
huddle_recipients.append(to_zulip_username(zephyr_sender))
|
huddle_recipients.append(to_zulip_username(zephyr_sender))
|
||||||
body = body.split("\n", 1)[1]
|
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),
|
", ".join(unauthorized),
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(skipped) > 0:
|
if len(skipped) > 0 and verbose:
|
||||||
if verbose:
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"\n%s\n",
|
"\n%s\n",
|
||||||
"\n".join(
|
"\n".join(
|
||||||
|
@ -1071,8 +1067,7 @@ Zulip subscription to these lines in ~/.zephyr.subs:
|
||||||
logger.info(" [%s,%s,%s] (%s)", cls, instance, recipient, reason)
|
logger.info(" [%s,%s,%s] (%s)", cls, instance, recipient, reason)
|
||||||
else:
|
else:
|
||||||
logger.info(" [%s,%s,%s]", cls, instance, recipient)
|
logger.info(" [%s,%s,%s]", cls, instance, recipient)
|
||||||
if len(skipped) > 0:
|
if len(skipped) > 0 and verbose:
|
||||||
if verbose:
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"\n%s\n",
|
"\n%s\n",
|
||||||
"\n".join(
|
"\n".join(
|
||||||
|
|
|
@ -501,8 +501,7 @@ class Client:
|
||||||
else: # we have a client cert
|
else: # we have a client cert
|
||||||
if not os.path.isfile(client_cert):
|
if not os.path.isfile(client_cert):
|
||||||
raise ConfigNotFoundError(f"client cert '{client_cert}' does not exist")
|
raise ConfigNotFoundError(f"client cert '{client_cert}' does not exist")
|
||||||
if client_cert_key is not None:
|
if client_cert_key is not None and not os.path.isfile(client_cert_key):
|
||||||
if not os.path.isfile(client_cert_key):
|
|
||||||
raise ConfigNotFoundError(f"client cert key '{client_cert_key}' does not exist")
|
raise ConfigNotFoundError(f"client cert key '{client_cert_key}' does not exist")
|
||||||
self.client_cert = client_cert
|
self.client_cert = client_cert
|
||||||
self.client_cert_key = client_cert_key
|
self.client_cert_key = client_cert_key
|
||||||
|
@ -652,8 +651,9 @@ class Client:
|
||||||
self.has_connected = True
|
self.has_connected = True
|
||||||
|
|
||||||
# On 50x errors, try again after a short sleep
|
# On 50x errors, try again after a short sleep
|
||||||
if str(res.status_code).startswith("5"):
|
if str(res.status_code).startswith("5") and error_retry(
|
||||||
if error_retry(f" (server {res.status_code})"):
|
f" (server {res.status_code})"
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
# Otherwise fall through and process the python-requests error normally
|
# Otherwise fall through and process the python-requests error normally
|
||||||
except (requests.exceptions.Timeout, requests.exceptions.SSLError) as e:
|
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"]
|
res_json["status"]["code"], res_json["status"]["errorDetails"]
|
||||||
)
|
)
|
||||||
if res_json["result"]["fulfillment"]["speech"] == "":
|
if res_json["result"]["fulfillment"]["speech"] == "":
|
||||||
if "alternateResult" in res_json.keys():
|
if (
|
||||||
if res_json["alternateResult"]["fulfillment"]["speech"] != "":
|
"alternateResult" in res_json.keys()
|
||||||
|
and res_json["alternateResult"]["fulfillment"]["speech"] != ""
|
||||||
|
):
|
||||||
return res_json["alternateResult"]["fulfillment"]["speech"]
|
return res_json["alternateResult"]["fulfillment"]["speech"]
|
||||||
return "Error. No result."
|
return "Error. No result."
|
||||||
return res_json["result"]["fulfillment"]["speech"]
|
return res_json["result"]["fulfillment"]["speech"]
|
||||||
|
|
|
@ -34,12 +34,10 @@ class MerelsModel:
|
||||||
merels = database.MerelsStorage(self.topic, self.storage)
|
merels = database.MerelsStorage(self.topic, self.storage)
|
||||||
data = game_data.GameData(merels.get_game_data(self.topic))
|
data = game_data.GameData(merels.get_game_data(self.topic))
|
||||||
|
|
||||||
if data.get_phase() > 1:
|
return data.get_phase() > 1 and (
|
||||||
if (mechanics.get_piece("X", data.grid()) <= 2) or (
|
(mechanics.get_piece("X", data.grid()) <= 2)
|
||||||
mechanics.get_piece("O", data.grid()) <= 2
|
or (mechanics.get_piece("O", data.grid()) <= 2)
|
||||||
):
|
)
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def make_move(self, move: str, player_number: int, computer_move: bool = False) -> Any:
|
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]':
|
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]:
|
def get_user_by_name(self, name: str) -> Dict[str, Any]:
|
||||||
name = name.strip()
|
name = name.strip()
|
||||||
for user in self.user_cache.values():
|
for user in self.user_cache.values():
|
||||||
if "full_name" in user.keys():
|
if "full_name" in user.keys() and user["full_name"].lower() == name.lower():
|
||||||
if user["full_name"].lower() == name.lower():
|
|
||||||
return user
|
return user
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@ -756,8 +755,7 @@ To move subjects, send your message again, otherwise join the game using the lin
|
||||||
return False
|
return False
|
||||||
for invite in self.invites.values():
|
for invite in self.invites.values():
|
||||||
for u in invite.keys():
|
for u in invite.keys():
|
||||||
if u == "host":
|
if u == "host" and user_email == invite["host"]:
|
||||||
if user_email == invite["host"]:
|
|
||||||
return False
|
return False
|
||||||
if u == user_email and "a" in invite[u]:
|
if u == user_email and "a" in invite[u]:
|
||||||
return False
|
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:
|
if private_recipients is not None:
|
||||||
for user in private_recipients:
|
for user in private_recipients:
|
||||||
self.send_message(user, content, True)
|
self.send_message(user, content, True)
|
||||||
if game_id in self.invites.keys():
|
if game_id in self.invites.keys() and self.invites[game_id]["subject"] != "###private###":
|
||||||
if self.invites[game_id]["subject"] != "###private###":
|
|
||||||
self.send_message(
|
self.send_message(
|
||||||
self.invites[game_id]["stream"],
|
self.invites[game_id]["stream"],
|
||||||
content,
|
content,
|
||||||
|
|
Loading…
Add table
Reference in a new issue