Techdebt: Replace string-format with f-strings (for p* dirs) (#5690)
This commit is contained in:
		
							parent
							
								
									a092763ce5
								
							
						
					
					
						commit
						5274da5431
					
				@ -42,7 +42,7 @@ class Lexicon(BaseModel):
 | 
			
		||||
                    self.language_code = value
 | 
			
		||||
 | 
			
		||||
        except Exception as err:
 | 
			
		||||
            raise ValueError("Failure parsing XML: {0}".format(err))
 | 
			
		||||
            raise ValueError(f"Failure parsing XML: {err}")
 | 
			
		||||
 | 
			
		||||
    def to_dict(self):
 | 
			
		||||
        return {
 | 
			
		||||
@ -57,7 +57,7 @@ class Lexicon(BaseModel):
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    def __repr__(self):
 | 
			
		||||
        return "<Lexicon {0}>".format(self.name)
 | 
			
		||||
        return f"<Lexicon {self.name}>"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PollyBackend(BaseBackend):
 | 
			
		||||
 | 
			
		||||
@ -39,11 +39,10 @@ class PollyResponse(BaseResponse):
 | 
			
		||||
        language_code = self._get_param("LanguageCode")
 | 
			
		||||
 | 
			
		||||
        if language_code is not None and language_code not in LANGUAGE_CODES:
 | 
			
		||||
            all_codes = ", ".join(LANGUAGE_CODES)
 | 
			
		||||
            msg = (
 | 
			
		||||
                "1 validation error detected: Value '{0}' at 'languageCode' failed to satisfy constraint: "
 | 
			
		||||
                "Member must satisfy enum value set: [{1}]".format(
 | 
			
		||||
                    language_code, ", ".join(LANGUAGE_CODES)
 | 
			
		||||
                )
 | 
			
		||||
                f"1 validation error detected: Value '{language_code}' at 'languageCode' failed to satisfy constraint: "
 | 
			
		||||
                f"Member must satisfy enum value set: [{all_codes}]"
 | 
			
		||||
            )
 | 
			
		||||
            return msg, dict(status=400)
 | 
			
		||||
 | 
			
		||||
@ -170,9 +169,8 @@ class PollyResponse(BaseResponse):
 | 
			
		||||
        if "VoiceId" not in self.json:
 | 
			
		||||
            return self._error("MissingParameter", "Missing parameter VoiceId")
 | 
			
		||||
        if self.json["VoiceId"] not in VOICE_IDS:
 | 
			
		||||
            return self._error(
 | 
			
		||||
                "InvalidParameterValue", "Not one of {0}".format(", ".join(VOICE_IDS))
 | 
			
		||||
            )
 | 
			
		||||
            all_voices = ", ".join(VOICE_IDS)
 | 
			
		||||
            return self._error("InvalidParameterValue", f"Not one of {all_voices}")
 | 
			
		||||
        args["voice_id"] = self.json["VoiceId"]
 | 
			
		||||
 | 
			
		||||
        # More validation
 | 
			
		||||
 | 
			
		||||
@ -1,2 +1,2 @@
 | 
			
		||||
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}"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user