mirror of https://github.com/zulip/zulip.git
ruff: Fix PIE810 Call `startswith` once with a `tuple`.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
b9fc5da350
commit
6992d3297a
|
@ -58,8 +58,7 @@ class PorticoDocumentationSpider(BaseDocumentationSpider):
|
||||||
def _is_external_url(self, url: str) -> bool:
|
def _is_external_url(self, url: str) -> bool:
|
||||||
return (
|
return (
|
||||||
not url.startswith("http://localhost:9981")
|
not url.startswith("http://localhost:9981")
|
||||||
or url.startswith("http://localhost:9981/help")
|
or url.startswith(("http://localhost:9981/help", "http://localhost:9981/api"))
|
||||||
or url.startswith("http://localhost:9981/api")
|
|
||||||
or self._has_extension(url)
|
or self._has_extension(url)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1157,7 +1157,7 @@ def export_usermessages_batch(
|
||||||
management command).
|
management command).
|
||||||
|
|
||||||
See write_message_partial_for_query for more context."""
|
See write_message_partial_for_query for more context."""
|
||||||
assert input_path.endswith(".partial") or input_path.endswith(".locked")
|
assert input_path.endswith((".partial", ".locked"))
|
||||||
assert output_path.endswith(".json")
|
assert output_path.endswith(".json")
|
||||||
|
|
||||||
with open(input_path, "rb") as input_file:
|
with open(input_path, "rb") as input_file:
|
||||||
|
|
|
@ -264,7 +264,7 @@ Output:
|
||||||
extensive test coverage of corner cases in the API to ensure that we've properly
|
extensive test coverage of corner cases in the API to ensure that we've properly
|
||||||
documented those corner cases.
|
documented those corner cases.
|
||||||
"""
|
"""
|
||||||
if not (url.startswith("/json") or url.startswith("/api/v1")):
|
if not url.startswith(("/json", "/api/v1")):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
content = orjson.loads(result.content)
|
content = orjson.loads(result.content)
|
||||||
|
|
|
@ -192,7 +192,7 @@ class Command(makemessages.Command):
|
||||||
for dirpath, dirnames, filenames in itertools.chain(
|
for dirpath, dirnames, filenames in itertools.chain(
|
||||||
os.walk("static/js"), os.walk("static/shared/js")
|
os.walk("static/js"), os.walk("static/shared/js")
|
||||||
):
|
):
|
||||||
for filename in [f for f in filenames if f.endswith(".js") or f.endswith(".ts")]:
|
for filename in [f for f in filenames if f.endswith((".js", ".ts"))]:
|
||||||
if filename.startswith("."):
|
if filename.startswith("."):
|
||||||
continue
|
continue
|
||||||
with open(os.path.join(dirpath, filename)) as reader:
|
with open(os.path.join(dirpath, filename)) as reader:
|
||||||
|
|
|
@ -113,11 +113,11 @@ def format_timedelta(timedelta: float) -> str:
|
||||||
def is_slow_query(time_delta: float, path: str) -> bool:
|
def is_slow_query(time_delta: float, path: str) -> bool:
|
||||||
if time_delta < 1.2:
|
if time_delta < 1.2:
|
||||||
return False
|
return False
|
||||||
is_exempt = (
|
is_exempt = path in [
|
||||||
path in ["/activity", "/json/report/error", "/api/v1/deployments/report_error"]
|
"/activity",
|
||||||
or path.startswith("/realm_activity/")
|
"/json/report/error",
|
||||||
or path.startswith("/user_activity/")
|
"/api/v1/deployments/report_error",
|
||||||
)
|
] or path.startswith(("/realm_activity/", "/user_activity/"))
|
||||||
if is_exempt:
|
if is_exempt:
|
||||||
return time_delta >= 5
|
return time_delta >= 5
|
||||||
if "webathena_kerberos" in path:
|
if "webathena_kerberos" in path:
|
||||||
|
|
|
@ -458,7 +458,7 @@ def get_subject_based_on_event(
|
||||||
if use_merge_request_title
|
if use_merge_request_title
|
||||||
else "",
|
else "",
|
||||||
)
|
)
|
||||||
elif event.startswith("Issue Hook") or event.startswith("Confidential Issue Hook"):
|
elif event.startswith(("Issue Hook", "Confidential Issue Hook")):
|
||||||
return TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
|
return TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
|
||||||
repo=get_repo_name(payload),
|
repo=get_repo_name(payload),
|
||||||
type="issue",
|
type="issue",
|
||||||
|
|
|
@ -12,10 +12,8 @@ def output_styler(style_func: Callable[[str], str]) -> Callable[[str], str]:
|
||||||
|
|
||||||
@wraps(style_func)
|
@wraps(style_func)
|
||||||
def _wrapped_style_func(message: str) -> str:
|
def _wrapped_style_func(message: str) -> str:
|
||||||
if (
|
if message == "Performing system checks...\n\n" or message.startswith(
|
||||||
message == "Performing system checks...\n\n"
|
("System check identified no issues", date_prefix)
|
||||||
or message.startswith("System check identified no issues")
|
|
||||||
or message.startswith(date_prefix)
|
|
||||||
):
|
):
|
||||||
message = ""
|
message = ""
|
||||||
elif "Quit the server with " in message:
|
elif "Quit the server with " in message:
|
||||||
|
|
Loading…
Reference in New Issue