ruff: Fix PLR1714 Consider merging multiple comparisons.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
192024ebc7
commit
93bb7eb61e
10 changed files with 16 additions and 16 deletions
|
@ -283,7 +283,7 @@ def maybe_restart_mirroring_script() -> None:
|
||||||
if os.stat(
|
if os.stat(
|
||||||
os.path.join(options.stamp_path, "stamps", "restart_stamp")
|
os.path.join(options.stamp_path, "stamps", "restart_stamp")
|
||||||
).st_mtime > start_time or (
|
).st_mtime > start_time or (
|
||||||
(options.user == "tabbott" or options.user == "tabbott/extra")
|
options.user in ("tabbott", "tabbott/extra")
|
||||||
and os.stat(os.path.join(options.stamp_path, "stamps", "tabbott_stamp")).st_mtime
|
and os.stat(os.path.join(options.stamp_path, "stamps", "tabbott_stamp")).st_mtime
|
||||||
> start_time
|
> start_time
|
||||||
):
|
):
|
||||||
|
@ -357,9 +357,9 @@ def process_loop(zulip_queue: "Queue[ZephyrDict]", log: Optional[IO[str]]) -> No
|
||||||
def parse_zephyr_body(zephyr_data: str, notice_format: str) -> Tuple[str, str]:
|
def parse_zephyr_body(zephyr_data: str, notice_format: str) -> Tuple[str, str]:
|
||||||
try:
|
try:
|
||||||
(zsig, body) = zephyr_data.split("\x00", 1)
|
(zsig, body) = zephyr_data.split("\x00", 1)
|
||||||
if (
|
if notice_format in (
|
||||||
notice_format == "New transaction [$1] entered in $2\nFrom: $3 ($5)\nSubject: $4"
|
"New transaction [$1] entered in $2\nFrom: $3 ($5)\nSubject: $4",
|
||||||
or notice_format == "New transaction [$1] entered in $2\nFrom: $3\nSubject: $4"
|
"New transaction [$1] entered in $2\nFrom: $3\nSubject: $4",
|
||||||
):
|
):
|
||||||
# Logic based off of owl_zephyr_get_message in barnowl
|
# Logic based off of owl_zephyr_get_message in barnowl
|
||||||
fields = body.split("\x00")
|
fields = body.split("\x00")
|
||||||
|
@ -789,7 +789,7 @@ Feedback button or at support@zulip.com."""
|
||||||
# Forward messages sent to '(instance "WHITESPACE")' back to the
|
# Forward messages sent to '(instance "WHITESPACE")' back to the
|
||||||
# appropriate WHITESPACE instance for bidirectional mirroring
|
# appropriate WHITESPACE instance for bidirectional mirroring
|
||||||
instance = match_whitespace_instance.group(1)
|
instance = match_whitespace_instance.group(1)
|
||||||
elif instance == f"instance {zephyr_class}" or instance == f"test instance {zephyr_class}":
|
elif instance in (f"instance {zephyr_class}", f"test instance {zephyr_class}"):
|
||||||
# Forward messages to e.g. -c -i white-magic back from the
|
# Forward messages to e.g. -c -i white-magic back from the
|
||||||
# place we forward them to
|
# place we forward them to
|
||||||
if instance.startswith("test"):
|
if instance.startswith("test"):
|
||||||
|
|
|
@ -23,7 +23,7 @@ def get_beeminder_response(message_content: str, config_info: Dict[str, str]) ->
|
||||||
auth_token = config_info["auth_token"]
|
auth_token = config_info["auth_token"]
|
||||||
|
|
||||||
message_content = message_content.strip()
|
message_content = message_content.strip()
|
||||||
if message_content == "" or message_content == "help":
|
if message_content in ("", "help"):
|
||||||
return help_message
|
return help_message
|
||||||
|
|
||||||
url = f"https://www.beeminder.com/api/v1/users/{username}/goals/{goalname}/datapoints.json"
|
url = f"https://www.beeminder.com/api/v1/users/{username}/goals/{goalname}/datapoints.json"
|
||||||
|
|
|
@ -84,7 +84,7 @@ def get_flock_response(content: str, config: Dict[str, str]) -> str:
|
||||||
|
|
||||||
def get_flock_bot_response(content: str, config: Dict[str, str]) -> None:
|
def get_flock_bot_response(content: str, config: Dict[str, str]) -> None:
|
||||||
content = content.strip()
|
content = content.strip()
|
||||||
if content == "" or content == "help":
|
if content in ("", "help"):
|
||||||
return help_message
|
return help_message
|
||||||
else:
|
else:
|
||||||
result = get_flock_response(content, config)
|
result = get_flock_response(content, config)
|
||||||
|
|
|
@ -95,7 +95,7 @@ def construct_grid(board):
|
||||||
grid = [[" " for _ in range(7)] for _ in range(7)]
|
grid = [[" " for _ in range(7)] for _ in range(7)]
|
||||||
|
|
||||||
for k, cell in enumerate(board):
|
for k, cell in enumerate(board):
|
||||||
if cell == "O" or cell == "X":
|
if cell in ("O", "X"):
|
||||||
grid[constants.ALLOWED_MOVES[k][0]][constants.ALLOWED_MOVES[k][1]] = cell
|
grid[constants.ALLOWED_MOVES[k][0]][constants.ALLOWED_MOVES[k][1]] = cell
|
||||||
|
|
||||||
return grid
|
return grid
|
||||||
|
@ -113,7 +113,7 @@ def construct_board(grid):
|
||||||
|
|
||||||
for cell_location in constants.ALLOWED_MOVES:
|
for cell_location in constants.ALLOWED_MOVES:
|
||||||
cell_content = grid[cell_location[0]][cell_location[1]]
|
cell_content = grid[cell_location[0]][cell_location[1]]
|
||||||
if cell_content == "X" or cell_content == "O":
|
if cell_content in ("X", "O"):
|
||||||
board += cell_content
|
board += cell_content
|
||||||
else:
|
else:
|
||||||
board += "N"
|
board += "N"
|
||||||
|
|
|
@ -56,11 +56,11 @@ def is_jump(vpos_before, hpos_before, vpos_after, hpos_after):
|
||||||
|
|
||||||
# If the man is in outer square, the distance must be 3 or 1
|
# If the man is in outer square, the distance must be 3 or 1
|
||||||
if [vpos_before, hpos_before] in constants.OUTER_SQUARE:
|
if [vpos_before, hpos_before] in constants.OUTER_SQUARE:
|
||||||
return not (distance == 3 or distance == 1)
|
return distance not in (3, 1)
|
||||||
|
|
||||||
# If the man is in middle square, the distance must be 2 or 1
|
# If the man is in middle square, the distance must be 2 or 1
|
||||||
if [vpos_before, hpos_before] in constants.MIDDLE_SQUARE:
|
if [vpos_before, hpos_before] in constants.MIDDLE_SQUARE:
|
||||||
return not (distance == 2 or distance == 1)
|
return distance not in (2, 1)
|
||||||
|
|
||||||
# If the man is in inner square, the distance must be only 1
|
# If the man is in inner square, the distance must be only 1
|
||||||
if [vpos_before, hpos_before] in constants.INNER_SQUARE:
|
if [vpos_before, hpos_before] in constants.INNER_SQUARE:
|
||||||
|
|
|
@ -144,7 +144,7 @@ class SalesforceHandler:
|
||||||
|
|
||||||
def get_salesforce_response(self, content: str) -> str:
|
def get_salesforce_response(self, content: str) -> str:
|
||||||
content = content.strip()
|
content = content.strip()
|
||||||
if content == "" or content == "help":
|
if content in ("", "help"):
|
||||||
return get_help_text()
|
return get_help_text()
|
||||||
if content.startswith("http") and "force" in content:
|
if content.startswith("http") and "force" in content:
|
||||||
return get_salesforce_link_details(content, self.sf)
|
return get_salesforce_link_details(content, self.sf)
|
||||||
|
|
|
@ -44,7 +44,7 @@ class StackOverflowHandler:
|
||||||
|
|
||||||
# Checking if the link exists.
|
# Checking if the link exists.
|
||||||
query = message["content"]
|
query = message["content"]
|
||||||
if query == "" or query == "help":
|
if query in ("", "help"):
|
||||||
return help_text
|
return help_text
|
||||||
|
|
||||||
query_stack_url = "http://api.stackexchange.com/2.2/search/advanced"
|
query_stack_url = "http://api.stackexchange.com/2.2/search/advanced"
|
||||||
|
|
|
@ -40,7 +40,7 @@ class SusiHandler:
|
||||||
|
|
||||||
def handle_message(self, message: Dict[str, str], bot_handler: BotHandler) -> None:
|
def handle_message(self, message: Dict[str, str], bot_handler: BotHandler) -> None:
|
||||||
msg = message["content"]
|
msg = message["content"]
|
||||||
if msg == "help" or msg == "":
|
if msg in ("help", ""):
|
||||||
bot_handler.send_reply(message, self.usage())
|
bot_handler.send_reply(message, self.usage())
|
||||||
return
|
return
|
||||||
reply = requests.get("https://api.susi.ai/susi/chat.json", params=dict(q=msg))
|
reply = requests.get("https://api.susi.ai/susi/chat.json", params=dict(q=msg))
|
||||||
|
|
|
@ -198,7 +198,7 @@ def fs_mkdir(fs: Dict[str, Any], user: str, fn: str) -> Tuple[Dict[str, Any], An
|
||||||
|
|
||||||
|
|
||||||
def fs_ls(fs: Dict[str, Any], user: str, fn: str) -> Tuple[Dict[str, Any], Any]:
|
def fs_ls(fs: Dict[str, Any], user: str, fn: str) -> Tuple[Dict[str, Any], Any]:
|
||||||
if fn == "." or fn == "":
|
if fn in (".", ""):
|
||||||
path = fs["user_paths"][user]
|
path = fs["user_paths"][user]
|
||||||
else:
|
else:
|
||||||
path, msg = make_path(fs, user, fn)
|
path, msg = make_path(fs, user, fn)
|
||||||
|
|
|
@ -567,7 +567,7 @@ class GameAdapter:
|
||||||
) or "p" not in parameter:
|
) or "p" not in parameter:
|
||||||
players = [self.invites[game_id]["host"]]
|
players = [self.invites[game_id]["host"]]
|
||||||
for player, accepted in self.invites[game_id].items():
|
for player, accepted in self.invites[game_id].items():
|
||||||
if player == "host" or player == "subject" or player == "stream":
|
if player in ("host", "subject", "stream"):
|
||||||
continue
|
continue
|
||||||
if parameter in accepted:
|
if parameter in accepted:
|
||||||
players.append(player)
|
players.append(player)
|
||||||
|
|
Loading…
Add table
Reference in a new issue