Merge pull request #2841 from asherf/warns
Fix some 'DeprecationWarning: invalid escape sequence' warnings and use str.format for string interpolation.
This commit is contained in:
commit
95e95cc97d
@ -582,11 +582,13 @@ class ELBv2Backend(BaseBackend):
|
||||
report='Missing required parameter in Actions[%s].FixedResponseConfig: "StatusCode"'
|
||||
% i
|
||||
)
|
||||
if not re.match(r"^(2|4|5)\d\d$", status_code):
|
||||
expression = r"^(2|4|5)\d\d$"
|
||||
if not re.match(expression, status_code):
|
||||
raise InvalidStatusCodeActionTypeError(
|
||||
"1 validation error detected: Value '%s' at 'actions.%s.member.fixedResponseConfig.statusCode' failed to satisfy constraint: \
|
||||
Member must satisfy regular expression pattern: ^(2|4|5)\d\d$"
|
||||
% (status_code, index)
|
||||
"1 validation error detected: Value '{}' at 'actions.{}.member.fixedResponseConfig.statusCode' failed to satisfy constraint: \
|
||||
Member must satisfy regular expression pattern: {}".format(
|
||||
status_code, index, expression
|
||||
)
|
||||
)
|
||||
content_type = action.data["fixed_response_config._content_type"]
|
||||
if content_type and content_type not in [
|
||||
@ -603,16 +605,19 @@ Member must satisfy regular expression pattern: ^(2|4|5)\d\d$"
|
||||
def create_target_group(self, name, **kwargs):
|
||||
if len(name) > 32:
|
||||
raise InvalidTargetGroupNameError(
|
||||
"Target group name '%s' cannot be longer than '32' characters" % name
|
||||
"Target group name '{}' cannot be longer than '32' characters".format(
|
||||
name
|
||||
)
|
||||
)
|
||||
if not re.match("^[a-zA-Z0-9\-]+$", name):
|
||||
if not re.match(r"^[a-zA-Z0-9\-]+$", name):
|
||||
raise InvalidTargetGroupNameError(
|
||||
"Target group name '%s' can only contain characters that are alphanumeric characters or hyphens(-)"
|
||||
% name
|
||||
"Target group name '{}' can only contain characters that are alphanumeric characters or hyphens(-)".format(
|
||||
name
|
||||
)
|
||||
)
|
||||
|
||||
# undocumented validation
|
||||
if not re.match("(?!.*--)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$", name):
|
||||
if not re.match(r"(?!.*--)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$", name):
|
||||
raise InvalidTargetGroupNameError(
|
||||
"1 validation error detected: Value '%s' at 'targetGroup.targetGroupArn.targetGroupName' failed to satisfy constraint: Member must satisfy regular expression pattern: (?!.*--)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$"
|
||||
% name
|
||||
|
@ -305,12 +305,12 @@ class EventsBackend(BaseBackend):
|
||||
|
||||
if principal is None or self.ACCOUNT_ID.match(principal) is None:
|
||||
raise JsonRESTError(
|
||||
"InvalidParameterValue", "Principal must match ^(\d{1,12}|\*)$"
|
||||
"InvalidParameterValue", r"Principal must match ^(\d{1,12}|\*)$"
|
||||
)
|
||||
|
||||
if statement_id is None or self.STATEMENT_ID.match(statement_id) is None:
|
||||
raise JsonRESTError(
|
||||
"InvalidParameterValue", "StatementId must match ^[a-zA-Z0-9-_]{1,64}$"
|
||||
"InvalidParameterValue", r"StatementId must match ^[a-zA-Z0-9-_]{1,64}$"
|
||||
)
|
||||
|
||||
event_bus._permissions[statement_id] = {
|
||||
|
@ -134,7 +134,7 @@ def parse_requestline(s):
|
||||
ValueError: Not a Request-Line
|
||||
"""
|
||||
methods = "|".join(HttpBaseClass.METHODS)
|
||||
m = re.match(r"(" + methods + ")\s+(.*)\s+HTTP/(1.[0|1])", s, re.I)
|
||||
m = re.match(r"({})\s+(.*)\s+HTTP/(1.[0|1])".format(methods), s, re.I)
|
||||
if m:
|
||||
return m.group(1).upper(), m.group(2), m.group(3)
|
||||
else:
|
||||
|
@ -89,7 +89,7 @@ def _exclude_characters(password, exclude_characters):
|
||||
for c in exclude_characters:
|
||||
if c in string.punctuation:
|
||||
# Escape punctuation regex usage
|
||||
c = "\{0}".format(c)
|
||||
c = r"\{0}".format(c)
|
||||
password = re.sub(c, "", str(password))
|
||||
return password
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user