Techdebt: Replace string-format with f-strings (for p* dirs) (#5690)

This commit is contained in:
Bert Blommers 2022-11-20 12:00:05 -01:00 committed by GitHub
parent a092763ce5
commit 5274da5431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 10 deletions

View File

@ -42,7 +42,7 @@ class Lexicon(BaseModel):
self.language_code = value self.language_code = value
except Exception as err: except Exception as err:
raise ValueError("Failure parsing XML: {0}".format(err)) raise ValueError(f"Failure parsing XML: {err}")
def to_dict(self): def to_dict(self):
return { return {
@ -57,7 +57,7 @@ class Lexicon(BaseModel):
} }
def __repr__(self): def __repr__(self):
return "<Lexicon {0}>".format(self.name) return f"<Lexicon {self.name}>"
class PollyBackend(BaseBackend): class PollyBackend(BaseBackend):

View File

@ -39,11 +39,10 @@ class PollyResponse(BaseResponse):
language_code = self._get_param("LanguageCode") language_code = self._get_param("LanguageCode")
if language_code is not None and language_code not in LANGUAGE_CODES: if language_code is not None and language_code not in LANGUAGE_CODES:
all_codes = ", ".join(LANGUAGE_CODES)
msg = ( msg = (
"1 validation error detected: Value '{0}' at 'languageCode' failed to satisfy constraint: " f"1 validation error detected: Value '{language_code}' at 'languageCode' failed to satisfy constraint: "
"Member must satisfy enum value set: [{1}]".format( f"Member must satisfy enum value set: [{all_codes}]"
language_code, ", ".join(LANGUAGE_CODES)
)
) )
return msg, dict(status=400) return msg, dict(status=400)
@ -170,9 +169,8 @@ class PollyResponse(BaseResponse):
if "VoiceId" not in self.json: if "VoiceId" not in self.json:
return self._error("MissingParameter", "Missing parameter VoiceId") return self._error("MissingParameter", "Missing parameter VoiceId")
if self.json["VoiceId"] not in VOICE_IDS: if self.json["VoiceId"] not in VOICE_IDS:
return self._error( all_voices = ", ".join(VOICE_IDS)
"InvalidParameterValue", "Not one of {0}".format(", ".join(VOICE_IDS)) return self._error("InvalidParameterValue", f"Not one of {all_voices}")
)
args["voice_id"] = self.json["VoiceId"] args["voice_id"] = self.json["VoiceId"]
# More validation # More validation

View File

@ -1,2 +1,2 @@
def make_arn_for_lexicon(account_id, name, region_name): def make_arn_for_lexicon(account_id, name, region_name):
return "arn:aws:polly:{0}:{1}:lexicon/{2}".format(region_name, account_id, name) return f"arn:aws:polly:{region_name}:{account_id}:lexicon/{name}"