notify-api-412 use black to enforce python style standards

This commit is contained in:
Kenneth Kehl
2023-08-23 10:35:43 -07:00
parent a7898118d7
commit 026dc14021
586 changed files with 33990 additions and 23461 deletions

View File

@@ -21,7 +21,7 @@ class AwsSnsClient(SmsClient):
region_name=cloud_config.sns_region,
aws_access_key_id=cloud_config.sns_access_key,
aws_secret_access_key=cloud_config.sns_secret_key,
config=AWS_CLIENT_CONFIG
config=AWS_CLIENT_CONFIG,
)
super(SmsClient, self).__init__(*args, **kwargs)
self.current_app = current_app
@@ -29,7 +29,7 @@ class AwsSnsClient(SmsClient):
@property
def name(self):
return 'sns'
return "sns"
def get_name(self):
return self.name
@@ -42,7 +42,9 @@ class AwsSnsClient(SmsClient):
for match in phonenumbers.PhoneNumberMatcher(to, "US"):
matched = True
to = phonenumbers.format_number(match.number, phonenumbers.PhoneNumberFormat.E164)
to = phonenumbers.format_number(
match.number, phonenumbers.PhoneNumberFormat.E164
)
# See documentation
# https://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html#sms_publish_sdk
@@ -66,14 +68,18 @@ class AwsSnsClient(SmsClient):
try:
start_time = monotonic()
response = self._client.publish(PhoneNumber=to, Message=content, MessageAttributes=attributes)
response = self._client.publish(
PhoneNumber=to, Message=content, MessageAttributes=attributes
)
except botocore.exceptions.ClientError as e:
raise str(e)
except Exception as e:
raise str(e)
finally:
elapsed_time = monotonic() - start_time
self.current_app.logger.info("AWS SNS request finished in {}".format(elapsed_time))
self.current_app.logger.info(
"AWS SNS request finished in {}".format(elapsed_time)
)
return response["MessageId"]
if not matched: