diff --git a/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.py b/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.py index 949b72e0bd..3eaf50b0bb 100644 --- a/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.py +++ b/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.py @@ -58,8 +58,7 @@ class PorticoDocumentationSpider(BaseDocumentationSpider): def _is_external_url(self, url: str) -> bool: return ( not url.startswith("http://localhost:9981") - or url.startswith("http://localhost:9981/help") - or url.startswith("http://localhost:9981/api") + or url.startswith(("http://localhost:9981/help", "http://localhost:9981/api")) or self._has_extension(url) ) diff --git a/zerver/lib/export.py b/zerver/lib/export.py index 6083a92d76..a9cd7d1d24 100644 --- a/zerver/lib/export.py +++ b/zerver/lib/export.py @@ -1157,7 +1157,7 @@ def export_usermessages_batch( management command). 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") with open(input_path, "rb") as input_file: diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index 464e8d7f6d..59a4acdff4 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -264,7 +264,7 @@ Output: extensive test coverage of corner cases in the API to ensure that we've properly documented those corner cases. """ - if not (url.startswith("/json") or url.startswith("/api/v1")): + if not url.startswith(("/json", "/api/v1")): return try: content = orjson.loads(result.content) diff --git a/zerver/management/commands/makemessages.py b/zerver/management/commands/makemessages.py index b2d9b5519c..073eed94de 100644 --- a/zerver/management/commands/makemessages.py +++ b/zerver/management/commands/makemessages.py @@ -192,7 +192,7 @@ class Command(makemessages.Command): for dirpath, dirnames, filenames in itertools.chain( 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("."): continue with open(os.path.join(dirpath, filename)) as reader: diff --git a/zerver/middleware.py b/zerver/middleware.py index da64558faf..eb0266c067 100644 --- a/zerver/middleware.py +++ b/zerver/middleware.py @@ -113,11 +113,11 @@ def format_timedelta(timedelta: float) -> str: def is_slow_query(time_delta: float, path: str) -> bool: if time_delta < 1.2: return False - is_exempt = ( - path in ["/activity", "/json/report/error", "/api/v1/deployments/report_error"] - or path.startswith("/realm_activity/") - or path.startswith("/user_activity/") - ) + is_exempt = path in [ + "/activity", + "/json/report/error", + "/api/v1/deployments/report_error", + ] or path.startswith(("/realm_activity/", "/user_activity/")) if is_exempt: return time_delta >= 5 if "webathena_kerberos" in path: diff --git a/zerver/webhooks/gitlab/view.py b/zerver/webhooks/gitlab/view.py index 6f47adc952..d961b89b2d 100644 --- a/zerver/webhooks/gitlab/view.py +++ b/zerver/webhooks/gitlab/view.py @@ -458,7 +458,7 @@ def get_subject_based_on_event( if use_merge_request_title 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( repo=get_repo_name(payload), type="issue", diff --git a/zilencer/management/commands/rundjangoserver.py b/zilencer/management/commands/rundjangoserver.py index 084be4a636..e3fb2d12f5 100644 --- a/zilencer/management/commands/rundjangoserver.py +++ b/zilencer/management/commands/rundjangoserver.py @@ -12,10 +12,8 @@ def output_styler(style_func: Callable[[str], str]) -> Callable[[str], str]: @wraps(style_func) def _wrapped_style_func(message: str) -> str: - if ( - message == "Performing system checks...\n\n" - or message.startswith("System check identified no issues") - or message.startswith(date_prefix) + if message == "Performing system checks...\n\n" or message.startswith( + ("System check identified no issues", date_prefix) ): message = "" elif "Quit the server with " in message: