ruff: Fix RUF021 Parenthesize when chaining `and` and `or` together.

This is a preview rule, not yet enabled by default.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-02-29 17:50:10 -08:00 committed by Tim Abbott
parent f618971668
commit 865febb307
5 changed files with 9 additions and 10 deletions

View File

@ -447,7 +447,7 @@ def print_line(
date = convert_from_nginx_date(match["date"])
else:
date = match["date"]
if args.all_logs or args.log_files is not None and args.log_files > 1:
if args.all_logs or (args.log_files is not None and args.log_files > 1):
ts = date + " " + match["time"]
else:
ts = match["time"]
@ -511,7 +511,7 @@ def print_line(
print(f"------------ {gap_ms:>5}ms gap ------------")
else:
print(f"!!!!!!!!!! {abs(gap_ms):>5}ms overlap !!!!!!!!!!")
if args.all_logs or args.log_files is not None and args.log_files > 1:
if args.all_logs or (args.log_files is not None and args.log_files > 1):
print(logline_start.isoformat(" ", timespec="milliseconds") + " (start)")
else:
print(logline_start.time().isoformat(timespec="milliseconds") + " (start)")

View File

@ -160,7 +160,7 @@ COMMON_YUM_DEPENDENCIES = [
BUILD_GROONGA_FROM_SOURCE = False
BUILD_PGROONGA_FROM_SOURCE = False
if vendor == "debian" and os_version in [] or vendor == "ubuntu" and os_version in []:
if (vendor == "debian" and os_version in []) or (vendor == "ubuntu" and os_version in []):
# For platforms without a PGroonga release, we need to build it
# from source.
BUILD_PGROONGA_FROM_SOURCE = True

View File

@ -674,7 +674,7 @@ def get_html_tag(text: str, i: int) -> str:
quote_count = 0
end = i + 1
unclosed_end = 0
while end < len(text) and (text[end] != ">" or quote_count % 2 != 0 and text[end] != "<"):
while end < len(text) and (text[end] != ">" or (quote_count % 2 != 0 and text[end] != "<")):
if text[end] == '"':
quote_count += 1
if not unclosed_end and text[end] == "<":

View File

@ -651,9 +651,8 @@ def flush_stream(
stream = instance
if (
update_fields is None
or "name" in update_fields
if update_fields is None or (
"name" in update_fields
and UserProfile.objects.filter(
Q(default_sending_stream=stream) | Q(default_events_register_stream=stream)
).exists()

View File

@ -1047,9 +1047,9 @@ def active_non_guest_user_ids(realm_id: int) -> List[int]:
def bot_owner_user_ids(user_profile: UserProfile) -> Set[int]:
is_private_bot = (
user_profile.default_sending_stream
and user_profile.default_sending_stream.invite_only
or user_profile.default_events_register_stream
user_profile.default_sending_stream and user_profile.default_sending_stream.invite_only
) or (
user_profile.default_events_register_stream
and user_profile.default_events_register_stream.invite_only
)
assert user_profile.bot_owner_id is not None