launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #30410
[Merge] ~cjwatson/launchpad:regex-warnings into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:regex-warnings into launchpad:master.
Commit message:
Silence "DeprecationWarning: invalid escape sequence"
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/450114
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:regex-warnings into launchpad:master.
diff --git a/lib/lp/answers/stories/questions-index.rst b/lib/lp/answers/stories/questions-index.rst
index 7aee544..2209188 100644
--- a/lib/lp/answers/stories/questions-index.rst
+++ b/lib/lp/answers/stories/questions-index.rst
@@ -54,7 +54,7 @@ The application footer also contains a sample of stats for the application:
>>> import re
>>> print(
... re.sub(
- ... "\d+",
+ ... r"\d+",
... "X",
... extract_text(
... find_tag_by_id(
diff --git a/lib/lp/app/stories/basics/xx-notifications.rst b/lib/lp/app/stories/basics/xx-notifications.rst
index bd7dca0..135b2c2 100644
--- a/lib/lp/app/stories/basics/xx-notifications.rst
+++ b/lib/lp/app/stories/basics/xx-notifications.rst
@@ -41,10 +41,10 @@ The notification messages should be propagated.
...
>>> import re
>>> destination_url = re.search(
- ... "(?m)^Location:\s(.*)$", str(result)
+ ... r"(?m)^Location:\s(.*)$", str(result)
... ).group(1)
>>> launchpad_session_cookie = re.search(
- ... "(?m)^Set-Cookie:\slaunchpad_tests=(.*?);", str(result)
+ ... r"(?m)^Set-Cookie:\slaunchpad_tests=(.*?);", str(result)
... ).group(1)
>>> print(
... http(
@@ -88,10 +88,10 @@ combined.
...
>>> destination_url = re.search(
- ... "(?m)^Location:\s(.*)$", str(result)
+ ... r"(?m)^Location:\s(.*)$", str(result)
... ).group(1)
>>> launchpad_session_cookie = re.search(
- ... "(?m)^Set-Cookie:\slaunchpad_tests=(.*?);", str(result)
+ ... r"(?m)^Set-Cookie:\slaunchpad_tests=(.*?);", str(result)
... ).group(1)
>>> print(
... http(
@@ -138,10 +138,10 @@ be needed.
...
>>> destination_url = re.search(
- ... "(?m)^Location:\s(.*)$", str(result)
+ ... r"(?m)^Location:\s(.*)$", str(result)
... ).group(1)
>>> launchpad_session_cookie = re.search(
- ... "(?m)^Set-Cookie:\slaunchpad_tests=(.*?);", str(result)
+ ... r"(?m)^Set-Cookie:\slaunchpad_tests=(.*?);", str(result)
... ).group(1)
>>> result = http(
... r"""
@@ -160,10 +160,10 @@ be needed.
...
>>> destination_url = re.search(
- ... "(?m)^Location:\s(.*)$", str(result)
+ ... r"(?m)^Location:\s(.*)$", str(result)
... ).group(1)
>>> launchpad_session_cookie = re.search(
- ... "(?m)^Set-Cookie:\slaunchpad_tests=(.*?);", str(result)
+ ... r"(?m)^Set-Cookie:\slaunchpad_tests=(.*?);", str(result)
... ).group(1)
>>> print(
... http(
diff --git a/lib/lp/app/validators/version.py b/lib/lp/app/validators/version.py
index ea06096..dbe16ca 100644
--- a/lib/lp/app/validators/version.py
+++ b/lib/lp/app/validators/version.py
@@ -107,7 +107,7 @@ def sane_version(version):
import re
if re.search(
- """^(?ix)
+ """(?ix)^
[0-9a-z]
( [0-9a-z] | [0-9a-z._-]*[0-9a-z] )*
$""",
diff --git a/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.rst b/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.rst
index ccf9feb..8b7c0a8 100644
--- a/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.rst
+++ b/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.rst
@@ -243,7 +243,7 @@ bug reporting guidelines can be changed, but admins do.
... pass
...
- >>> edit_url_re = re.compile(".*/\+edit$")
+ >>> edit_url_re = re.compile(r".*/\+edit$")
>>> for context_name, context_path, view in contexts:
... overview_url = "http://launchpad.test/%s" % (context_path,)
... print("* " + context_name)
diff --git a/lib/lp/services/database/doc/textsearching.rst b/lib/lp/services/database/doc/textsearching.rst
index e6da7fa..c374934 100644
--- a/lib/lp/services/database/doc/textsearching.rst
+++ b/lib/lp/services/database/doc/textsearching.rst
@@ -268,7 +268,7 @@ Punctuation is handled consistently. If a string containing punctuation
appears in an FTI, it can also be passed to ftq(),and a search for this
string finds the indexed text.
- >>> punctuation = "'\"#$%*+,./:;<=>?@[\]^`{}~"
+ >>> punctuation = "'\"#$%*+,./:;<=>?@[\\]^`{}~"
>>> for symbol in punctuation:
... print(repr(symbol), search_same("foo%sbar" % symbol))
...
diff --git a/lib/lp/services/librarian/doc/librarian.rst b/lib/lp/services/librarian/doc/librarian.rst
index d24ea39..821a98b 100644
--- a/lib/lp/services/librarian/doc/librarian.rst
+++ b/lib/lp/services/librarian/doc/librarian.rst
@@ -290,7 +290,7 @@ because, except for test cases, the URL is the only thing useful
(because the client can't see the database records yet).
>>> import re
- >>> match = re.search("/(\d+)/", url)
+ >>> match = re.search(r"/(\d+)/", url)
>>> alias_id = int(match.group(1))
>>> alias = lfas[alias_id]
>>> print(alias.expires.isoformat())
diff --git a/lib/lp/services/temporaryblobstorage/stories/xx-tempstorage.rst b/lib/lp/services/temporaryblobstorage/stories/xx-tempstorage.rst
index d625235..a7736e8 100644
--- a/lib/lp/services/temporaryblobstorage/stories/xx-tempstorage.rst
+++ b/lib/lp/services/temporaryblobstorage/stories/xx-tempstorage.rst
@@ -17,7 +17,7 @@ middle of the data so we can ensure binary data is handled correctly.
>>> import re
>>> match = re.search(
- ... "Your ticket is "([\w-]+)"", anon_browser.contents
+ ... r"Your ticket is "([\w-]+)"", anon_browser.contents
... )
>>> match is not None
True
diff --git a/lib/lp/services/webapp/publisher.py b/lib/lp/services/webapp/publisher.py
index 9dbd59c..4702b67 100644
--- a/lib/lp/services/webapp/publisher.py
+++ b/lib/lp/services/webapp/publisher.py
@@ -81,7 +81,7 @@ from lp.services.webapp.vhosts import allvhosts
error_status(http.client.NOT_FOUND)(NotFound)
# Used to match zope namespaces eg ++model++.
-RESERVED_NAMESPACE = re.compile("\\+\\+.*\\+\\+")
+RESERVED_NAMESPACE = re.compile(r"\+\+.*\+\+")
class DecoratorAnnotator:
diff --git a/lib/lp/services/webapp/tests/login.rst b/lib/lp/services/webapp/tests/login.rst
index 38ec6cc..48a5e13 100644
--- a/lib/lp/services/webapp/tests/login.rst
+++ b/lib/lp/services/webapp/tests/login.rst
@@ -42,7 +42,7 @@ the query args preserved.
>>> browser.urlpath
'/people'
>>> import re
- >>> print(pretty(sorted(re.sub(".*\?", "", browser.url).split("&"))))
+ >>> print(pretty(sorted(re.sub(r".*\?", "", browser.url).split("&"))))
['name=foo', 'searchfor=all']
If we load the +login page while already logged in, it will say we're already
@@ -83,5 +83,5 @@ name.
>>> browser.urlpath
'/people'
>>> import re
- >>> print(pretty(sorted(re.sub(".*\?", "", browser.url).split("&"))))
+ >>> print(pretty(sorted(re.sub(r".*\?", "", browser.url).split("&"))))
['name=foo', 'searchfor=all']
diff --git a/lib/lp/translations/stories/standalone/xx-translation-access-display.rst b/lib/lp/translations/stories/standalone/xx-translation-access-display.rst
index 2e5bc3a..f4de527 100644
--- a/lib/lp/translations/stories/standalone/xx-translation-access-display.rst
+++ b/lib/lp/translations/stories/standalone/xx-translation-access-display.rst
@@ -84,7 +84,7 @@ If the two groups are identical, however, it is only listed once.
>>> managers_tag = find_tag_by_id(
... admin_browser.contents, "translation-managers"
... ).decode_contents()
- >>> print(re.search(",\s+and", managers_tag))
+ >>> print(re.search(r",\s+and", managers_tag))
None
If no translation group is assigned, the page also mentions that.
diff --git a/lib/lp/translations/stories/translationgroups/xx-translationgroups.rst b/lib/lp/translations/stories/translationgroups/xx-translationgroups.rst
index 17cb339..c4f2053 100644
--- a/lib/lp/translations/stories/translationgroups/xx-translationgroups.rst
+++ b/lib/lp/translations/stories/translationgroups/xx-translationgroups.rst
@@ -1003,7 +1003,7 @@ The translation-managers detail may use ", and" to separate items, but
since there is only one item in this case, we don't see that.
>>> import re
- >>> print(re.search("\band\b", managers))
+ >>> print(re.search(r"\band\b", managers))
None
>>> print(get_detail_tag(browser, "translation-access"))
diff --git a/lib/lp/translations/utilities/doc/gettext_po_parser.rst b/lib/lp/translations/utilities/doc/gettext_po_parser.rst
index 76710a3..cb1f9cd 100644
--- a/lib/lp/translations/utilities/doc/gettext_po_parser.rst
+++ b/lib/lp/translations/utilities/doc/gettext_po_parser.rst
@@ -57,7 +57,7 @@ as an error.
Unrecognized escape sequences are caught as well.
- >>> parser.parse(b'msgid "\!"\nmsgstr ""\n') # noqa
+ >>> parser.parse(b'msgid "\\!"\nmsgstr ""\n') # noqa
Traceback (most recent call last):
...
lp.translations.interfaces.translationimporter.TranslationFormatSyntaxError: ...Unknown escape sequence...
diff --git a/utilities/community-contributions.py b/utilities/community-contributions.py
index 4999cde..fe82b78 100755
--- a/utilities/community-contributions.py
+++ b/utilities/community-contributions.py
@@ -409,7 +409,7 @@ class ExCon():
# If name is "Veronica Random <veronica {_AT_} example.com>",
# then name_as_anchor will be "veronica_random".
self.name_as_anchor = \
- re.compile("\\s+").sub("_", name.split("<")[0].strip()).lower()
+ re.compile(r"\s+").sub("_", name.split("<")[0].strip()).lower()
# All the top-level revisions this contributor is associated with
# (key == value == ContainerRevision). We use a dictionary
# instead of list to get set semantics; set() would be overkill.