ruff: Fix PERF401 Use a list comprehension to create a transformed list.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-07-31 13:52:35 -07:00
committed by Tim Abbott
parent 0b95d83f09
commit 562a79ab76
48 changed files with 495 additions and 674 deletions

View File

@@ -47,15 +47,16 @@ def test_generated_curl_examples_for_success(client: Client) -> None:
for endpoint in endpoint_list:
article_name = endpoint + ".md"
file_name = os.path.join(settings.DEPLOY_ROOT, "api_docs/", article_name)
curl_commands_to_test = []
if os.path.exists(file_name):
with open(file_name) as f:
for line in f:
curl_commands_to_test = [
# A typical example from the Markdown source looks like this:
# {generate_code_example(curl)|...|...}
if line.startswith("{generate_code_example(curl"):
curl_commands_to_test.append(line)
line
for line in f
if line.startswith("{generate_code_example(curl")
]
else:
# If the file doesn't exist, then it has been
# deleted and its page is generated by the
@@ -64,7 +65,7 @@ def test_generated_curl_examples_for_success(client: Client) -> None:
endpoint_path, endpoint_method = get_endpoint_from_operationid(endpoint)
endpoint_string = endpoint_path + ":" + endpoint_method
command = f"{{generate_code_example(curl)|{endpoint_string}|example}}"
curl_commands_to_test.append(command)
curl_commands_to_test = [command]
for line in curl_commands_to_test:
# To do an end-to-end test on the documentation examples