Skip to content

Commit 2f58129

Browse files
committed
ruff: Fix FLY002 Consider f-string instead of string join.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent fcd4fe3 commit 2f58129

File tree

2 files changed

+7
-45
lines changed

2 files changed

+7
-45
lines changed

zulip_bots/zulip_bots/bots/baremetrics/baremetrics.py

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,7 @@ def get_plans(self, source_id: str) -> str:
154154
plans_data = plans_response.json()
155155
plans_data = plans_data["plans"]
156156

157-
template = "\n".join(
158-
[
159-
"{_count}.Name: {name}",
160-
"Active: {active}",
161-
"Interval: {interval}",
162-
"Interval Count: {interval_count}",
163-
"Amounts:",
164-
]
165-
)
157+
template = "{_count}.Name: {name}\nActive: {active}\nInterval: {interval}\nInterval Count: {interval_count}\nAmounts:"
166158
response = ["**Listing plans:**"]
167159
for index, plan in enumerate(plans_data):
168160
response += (
@@ -181,17 +173,7 @@ def get_customers(self, source_id: str) -> str:
181173
customers_data = customers_data["customers"]
182174

183175
# FIXME BUG here? mismatch of name and display name?
184-
template = "\n".join(
185-
[
186-
"{_count}.Name: {display_name}",
187-
"Display Name: {name}",
188-
"OID: {oid}",
189-
"Active: {is_active}",
190-
"Email: {email}",
191-
"Notes: {notes}",
192-
"Current Plans:",
193-
]
194-
)
176+
template = "{_count}.Name: {display_name}\nDisplay Name: {name}\nOID: {oid}\nActive: {is_active}\nEmail: {email}\nNotes: {notes}\nCurrent Plans:"
195177
response = ["**Listing customers:**"]
196178
for index, customer in enumerate(customers_data):
197179
response += (
@@ -209,17 +191,7 @@ def get_subscriptions(self, source_id: str) -> str:
209191
subscriptions_data = subscriptions_response.json()
210192
subscriptions_data = subscriptions_data["subscriptions"]
211193

212-
template = "\n".join(
213-
[
214-
"{_count}.Customer Name: {name}",
215-
"Customer Display Name: {display_name}",
216-
"Customer OID: {oid}",
217-
"Customer Email: {email}",
218-
"Active: {_active}",
219-
"Plan Name: {_plan_name}",
220-
"Plan Amounts:",
221-
]
222-
)
194+
template = "{_count}.Customer Name: {name}\nCustomer Display Name: {display_name}\nCustomer OID: {oid}\nCustomer Email: {email}\nActive: {_active}\nPlan Name: {_plan_name}\nPlan Amounts:"
223195
response = ["**Listing subscriptions:**"]
224196
for index, subscription in enumerate(subscriptions_data):
225197
response += (

zulip_bots/zulip_bots/bots/idonethis/idonethis.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ def get_team_hash(team_name: str) -> str:
9797

9898
def team_info(team_name: str) -> str:
9999
data = api_show_team(get_team_hash(team_name))
100-
return "\n".join(["Team Name: {name}", "ID: `{hash_id}`", "Created at: {created_at}"]).format(
101-
**data
102-
)
100+
return "Team Name: {name}\nID: `{hash_id}`\nCreated at: {created_at}".format(**data)
103101

104102

105103
def entries_list(team_name: str) -> str:
@@ -110,17 +108,9 @@ def entries_list(team_name: str) -> str:
110108
data = api_list_entries()
111109
response = "Entries for all teams:"
112110
for entry in data:
113-
response += "\n".join(
114-
[
115-
"",
116-
" * {body_formatted}",
117-
" * Created at: {created_at}",
118-
" * Status: {status}",
119-
" * User: {username}",
120-
" * Team: {teamname}",
121-
" * ID: {hash_id}",
122-
]
123-
).format(username=entry["user"]["full_name"], teamname=entry["team"]["name"], **entry)
111+
response += "\n * {body_formatted}\n * Created at: {created_at}\n * Status: {status}\n * User: {username}\n * Team: {teamname}\n * ID: {hash_id}".format(
112+
username=entry["user"]["full_name"], teamname=entry["team"]["name"], **entry
113+
)
124114
return response
125115

126116

0 commit comments

Comments
 (0)