Skip to content

Commit 93bb7eb

Browse files
committed
ruff: Fix PLR1714 Consider merging multiple comparisons.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 192024e commit 93bb7eb

File tree

10 files changed

+16
-16
lines changed

10 files changed

+16
-16
lines changed

zulip/integrations/zephyr/zephyr_mirror_backend.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def maybe_restart_mirroring_script() -> None:
283283
if os.stat(
284284
os.path.join(options.stamp_path, "stamps", "restart_stamp")
285285
).st_mtime > start_time or (
286-
(options.user == "tabbott" or options.user == "tabbott/extra")
286+
options.user in ("tabbott", "tabbott/extra")
287287
and os.stat(os.path.join(options.stamp_path, "stamps", "tabbott_stamp")).st_mtime
288288
> start_time
289289
):
@@ -357,9 +357,9 @@ def process_loop(zulip_queue: "Queue[ZephyrDict]", log: Optional[IO[str]]) -> No
357357
def parse_zephyr_body(zephyr_data: str, notice_format: str) -> Tuple[str, str]:
358358
try:
359359
(zsig, body) = zephyr_data.split("\x00", 1)
360-
if (
361-
notice_format == "New transaction [$1] entered in $2\nFrom: $3 ($5)\nSubject: $4"
362-
or notice_format == "New transaction [$1] entered in $2\nFrom: $3\nSubject: $4"
360+
if notice_format in (
361+
"New transaction [$1] entered in $2\nFrom: $3 ($5)\nSubject: $4",
362+
"New transaction [$1] entered in $2\nFrom: $3\nSubject: $4",
363363
):
364364
# Logic based off of owl_zephyr_get_message in barnowl
365365
fields = body.split("\x00")
@@ -789,7 +789,7 @@ def forward_to_zephyr(message: Dict[str, Any], zulip_client: zulip.Client) -> No
789789
# Forward messages sent to '(instance "WHITESPACE")' back to the
790790
# appropriate WHITESPACE instance for bidirectional mirroring
791791
instance = match_whitespace_instance.group(1)
792-
elif instance == f"instance {zephyr_class}" or instance == f"test instance {zephyr_class}":
792+
elif instance in (f"instance {zephyr_class}", f"test instance {zephyr_class}"):
793793
# Forward messages to e.g. -c -i white-magic back from the
794794
# place we forward them to
795795
if instance.startswith("test"):

zulip_bots/zulip_bots/bots/beeminder/beeminder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_beeminder_response(message_content: str, config_info: Dict[str, str]) ->
2323
auth_token = config_info["auth_token"]
2424

2525
message_content = message_content.strip()
26-
if message_content == "" or message_content == "help":
26+
if message_content in ("", "help"):
2727
return help_message
2828

2929
url = f"https://www.beeminder.com/api/v1/users/{username}/goals/{goalname}/datapoints.json"

zulip_bots/zulip_bots/bots/flock/flock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def get_flock_response(content: str, config: Dict[str, str]) -> str:
8484

8585
def get_flock_bot_response(content: str, config: Dict[str, str]) -> None:
8686
content = content.strip()
87-
if content == "" or content == "help":
87+
if content in ("", "help"):
8888
return help_message
8989
else:
9090
result = get_flock_response(content, config)

zulip_bots/zulip_bots/bots/merels/libraries/interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def construct_grid(board):
9595
grid = [[" " for _ in range(7)] for _ in range(7)]
9696

9797
for k, cell in enumerate(board):
98-
if cell == "O" or cell == "X":
98+
if cell in ("O", "X"):
9999
grid[constants.ALLOWED_MOVES[k][0]][constants.ALLOWED_MOVES[k][1]] = cell
100100

101101
return grid
@@ -113,7 +113,7 @@ def construct_board(grid):
113113

114114
for cell_location in constants.ALLOWED_MOVES:
115115
cell_content = grid[cell_location[0]][cell_location[1]]
116-
if cell_content == "X" or cell_content == "O":
116+
if cell_content in ("X", "O"):
117117
board += cell_content
118118
else:
119119
board += "N"

zulip_bots/zulip_bots/bots/merels/libraries/mechanics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ def is_jump(vpos_before, hpos_before, vpos_after, hpos_after):
5656

5757
# If the man is in outer square, the distance must be 3 or 1
5858
if [vpos_before, hpos_before] in constants.OUTER_SQUARE:
59-
return not (distance == 3 or distance == 1)
59+
return distance not in (3, 1)
6060

6161
# If the man is in middle square, the distance must be 2 or 1
6262
if [vpos_before, hpos_before] in constants.MIDDLE_SQUARE:
63-
return not (distance == 2 or distance == 1)
63+
return distance not in (2, 1)
6464

6565
# If the man is in inner square, the distance must be only 1
6666
if [vpos_before, hpos_before] in constants.INNER_SQUARE:

zulip_bots/zulip_bots/bots/salesforce/salesforce.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def usage(self) -> str:
144144

145145
def get_salesforce_response(self, content: str) -> str:
146146
content = content.strip()
147-
if content == "" or content == "help":
147+
if content in ("", "help"):
148148
return get_help_text()
149149
if content.startswith("http") and "force" in content:
150150
return get_salesforce_link_details(content, self.sf)

zulip_bots/zulip_bots/bots/stack_overflow/stack_overflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def get_bot_stackoverflow_response(
4444

4545
# Checking if the link exists.
4646
query = message["content"]
47-
if query == "" or query == "help":
47+
if query in ("", "help"):
4848
return help_text
4949

5050
query_stack_url = "http://api.stackexchange.com/2.2/search/advanced"

zulip_bots/zulip_bots/bots/susi/susi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def usage(self) -> str:
4040

4141
def handle_message(self, message: Dict[str, str], bot_handler: BotHandler) -> None:
4242
msg = message["content"]
43-
if msg == "help" or msg == "":
43+
if msg in ("help", ""):
4444
bot_handler.send_reply(message, self.usage())
4545
return
4646
reply = requests.get("https://api.susi.ai/susi/chat.json", params=dict(q=msg))

zulip_bots/zulip_bots/bots/virtual_fs/virtual_fs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def fs_mkdir(fs: Dict[str, Any], user: str, fn: str) -> Tuple[Dict[str, Any], An
198198

199199

200200
def fs_ls(fs: Dict[str, Any], user: str, fn: str) -> Tuple[Dict[str, Any], Any]:
201-
if fn == "." or fn == "":
201+
if fn in (".", ""):
202202
path = fs["user_paths"][user]
203203
else:
204204
path, msg = make_path(fs, user, fn)

zulip_bots/zulip_bots/game_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def get_players(self, game_id: str, parameter: str = "a") -> List[str]:
567567
) or "p" not in parameter:
568568
players = [self.invites[game_id]["host"]]
569569
for player, accepted in self.invites[game_id].items():
570-
if player == "host" or player == "subject" or player == "stream":
570+
if player in ("host", "subject", "stream"):
571571
continue
572572
if parameter in accepted:
573573
players.append(player)

0 commit comments

Comments
 (0)