File .deepsource.toml
not found in the default branch of the repository root. Please refer to the docs.
1004 if len(customer_balances_adjustment) == 0:
1005 return Response(
1006 {
1007 "error_detail": "CustomerBalanceAdjustmentView with customer_id {} does not exist".format(1008 customer_id
1009 )
1010 },
75 subject = f"Join {organization_name} in Lotus"
76 body = f"Use this link to join {organization_name} team: {reset_url}"
77 from_email = f"Lotus <{DEFAULT_FROM_EMAIL}>"
78 html = """79 <p>Register to <a href={url}>join {organization_name}</a> team</p>""".format(
80 url=reset_url, organization_name=organization_name
81 )
60 token_object.expire_at = now_plus_day()
61 token_object.save()
62 path = "register?token=%s" % (token_object.token)
63 password_reset_url = "%s/%s" % (settings.APP_URL, path)64
65 send_invite_email(
66 reset_url=password_reset_url,
59 token_object.user = user
60 token_object.expire_at = now_plus_day()
61 token_object.save()
62 path = "register?token=%s" % (token_object.token)63 password_reset_url = "%s/%s" % (settings.APP_URL, path)
64
65 send_invite_email(
140 try:
141 stripe_pi = stripe.Invoice.retrieve(invoice.external_payment_obj_id)
142 except Exception as e:
143 assert False, "Payment intent not found for reason: {}".format(e)144
145 # update the status of the invoice
146 new_status = stripe_connector.update_payment_object_status(
f-strings are the fastest way to format strings as compared to the following methods:
%
format()
str.join
+
operator to concatinate stringTemplate.substitute
Some less preferred ways to format strings are the following:
from string import Template
menu = ('eggs', 'spam', 42.4)
old_order = "%s and %s: %.2f ¤" % menu # [consider-using-f-string]
beginner_order = menu[0] + " and " + menu[1] + ": " + str(menu[2]) + " ¤"
joined_order = " and ".join(menu[:2])
format_order = "{} and {}: {:0.2f} ¤".format(menu[0], menu[1], menu[2])
named_format_order = "{eggs} and {spam}: {price:0.2f} ¤".format(eggs=menu[0], spam=menu[1], price=menu[2])
template_order = Template('$eggs and $spam: $price ¤').substitute(eggs=menu[0], spam=menu[1], price=menu[2])
Consider using f-strings as shown below:
menu = ('eggs', 'spam', 42.4)
f_string_order = f"{menu[0]} and {menu[1]}: {menu[2]:0.2f} ¤"