← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:flake8-w605 into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:flake8-w605 into launchpad:master.

Commit message:
flake8: Fix W605 invalid escape sequence

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/406624

These are all regexes, so use `r""` literals to indicate that we intend to pass the backslash literally through to `re`.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:flake8-w605 into launchpad:master.
diff --git a/lib/lp/app/validators/validation.py b/lib/lp/app/validators/validation.py
index 1ddbf6c..244aec9 100644
--- a/lib/lp/app/validators/validation.py
+++ b/lib/lp/app/validators/validation.py
@@ -96,7 +96,7 @@ def validate_oci_branch_name(branch_name):
     app_version = split[0:-1]
     ubuntu_version = split[-1]
     # 20.04 format
-    ubuntu_match = re.match("\d{2}\.\d{2}", ubuntu_version)
+    ubuntu_match = re.match(r"\d{2}\.\d{2}", ubuntu_version)
     if not ubuntu_match:
         return False
     # disallow risks in app version number
diff --git a/utilities/format-imports b/utilities/format-imports
index 1606a8a..5e93624 100755
--- a/utilities/format-imports
+++ b/utilities/format-imports
@@ -151,7 +151,7 @@ from_import_multi_regex = re.compile(
     re.M)
 comment_regex = re.compile(
     "(?P<comment>(^#.+\n)+)(^import|^from) +(?P<module>[a-zA-Z0-9_.]+)", re.M)
-split_regex = re.compile(",\s*")
+split_regex = re.compile(r",\s*")
 
 # The base part of an import is its leading part: either a series of
 # dots, or a leading identifier.
diff --git a/utilities/make-lp-user b/utilities/make-lp-user
index e52cf8e..9d22fa3 100755
--- a/utilities/make-lp-user
+++ b/utilities/make-lp-user
@@ -119,7 +119,7 @@ def add_ssh_public_keys(person):
 
 def parse_fingerprints(gpg_output):
     """Find key fingerprints in "gpg --fingerprint <email>" output."""
-    line_prefix = re.compile('\s*Key fingerprint\s*=\s*')
+    line_prefix = re.compile(r'\s*Key fingerprint\s*=\s*')
     return [
         ''.join(re.sub(line_prefix, '', line).split())
         for line in gpg_output.splitlines()