ruff: Fix FLY002 Consider f-string instead of string join.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-27 22:07:21 -07:00
parent fcd4fe330d
commit 2f581293d9
2 changed files with 7 additions and 45 deletions

View file

@ -154,15 +154,7 @@ class BaremetricsHandler:
plans_data = plans_response.json()
plans_data = plans_data["plans"]
template = "\n".join(
[
"{_count}.Name: {name}",
"Active: {active}",
"Interval: {interval}",
"Interval Count: {interval_count}",
"Amounts:",
]
)
template = "{_count}.Name: {name}\nActive: {active}\nInterval: {interval}\nInterval Count: {interval_count}\nAmounts:"
response = ["**Listing plans:**"]
for index, plan in enumerate(plans_data):
response += (
@ -181,17 +173,7 @@ class BaremetricsHandler:
customers_data = customers_data["customers"]
# FIXME BUG here? mismatch of name and display name?
template = "\n".join(
[
"{_count}.Name: {display_name}",
"Display Name: {name}",
"OID: {oid}",
"Active: {is_active}",
"Email: {email}",
"Notes: {notes}",
"Current Plans:",
]
)
template = "{_count}.Name: {display_name}\nDisplay Name: {name}\nOID: {oid}\nActive: {is_active}\nEmail: {email}\nNotes: {notes}\nCurrent Plans:"
response = ["**Listing customers:**"]
for index, customer in enumerate(customers_data):
response += (
@ -209,17 +191,7 @@ class BaremetricsHandler:
subscriptions_data = subscriptions_response.json()
subscriptions_data = subscriptions_data["subscriptions"]
template = "\n".join(
[
"{_count}.Customer Name: {name}",
"Customer Display Name: {display_name}",
"Customer OID: {oid}",
"Customer Email: {email}",
"Active: {_active}",
"Plan Name: {_plan_name}",
"Plan Amounts:",
]
)
template = "{_count}.Customer Name: {name}\nCustomer Display Name: {display_name}\nCustomer OID: {oid}\nCustomer Email: {email}\nActive: {_active}\nPlan Name: {_plan_name}\nPlan Amounts:"
response = ["**Listing subscriptions:**"]
for index, subscription in enumerate(subscriptions_data):
response += (

View file

@ -97,9 +97,7 @@ def get_team_hash(team_name: str) -> str:
def team_info(team_name: str) -> str:
data = api_show_team(get_team_hash(team_name))
return "\n".join(["Team Name: {name}", "ID: `{hash_id}`", "Created at: {created_at}"]).format(
**data
)
return "Team Name: {name}\nID: `{hash_id}`\nCreated at: {created_at}".format(**data)
def entries_list(team_name: str) -> str:
@ -110,17 +108,9 @@ def entries_list(team_name: str) -> str:
data = api_list_entries()
response = "Entries for all teams:"
for entry in data:
response += "\n".join(
[
"",
" * {body_formatted}",
" * Created at: {created_at}",
" * Status: {status}",
" * User: {username}",
" * Team: {teamname}",
" * ID: {hash_id}",
]
).format(username=entry["user"]["full_name"], teamname=entry["team"]["name"], **entry)
response += "\n * {body_formatted}\n * Created at: {created_at}\n * Status: {status}\n * User: {username}\n * Team: {teamname}\n * ID: {hash_id}".format(
username=entry["user"]["full_name"], teamname=entry["team"]["name"], **entry
)
return response