From f87c9ee5e951a8a67e35b3bdc4b2591e7338d758 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Thu, 19 Sep 2019 17:34:55 +0900 Subject: [PATCH] Fix DeprecationWarning: invalid escape sequence When running "tox -e pep8", "DeprecationWarning: invalid escape sequence" are shown. This is because a normal string contains escape sequences. Escape sequences need to be placed in raw strings. TrivialFix Change-Id: I34f63d90f53b721e9afdeb99ac53ef0c24857b17 --- glance/hacking/checks.py | 4 ++-- glance/tests/functional/test_reload.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/glance/hacking/checks.py b/glance/hacking/checks.py index 48fe0019c3..b1771e0088 100644 --- a/glance/hacking/checks.py +++ b/glance/hacking/checks.py @@ -32,10 +32,10 @@ Guidelines for writing new hacking checks asse_trueinst_re = re.compile( r"(.)*assertTrue\(isinstance\((\w|\.|\'|\"|\[|\])+, " - "(\w|\.|\'|\"|\[|\])+\)\)") + r"(\w|\.|\'|\"|\[|\])+\)\)") asse_equal_type_re = re.compile( r"(.)*assertEqual\(type\((\w|\.|\'|\"|\[|\])+\), " - "(\w|\.|\'|\"|\[|\])+\)") + r"(\w|\.|\'|\"|\[|\])+\)") asse_equal_end_with_none_re = re.compile( r"(.)*assertEqual\((\w|\.|\'|\"|\[|\])+, None\)") asse_equal_start_with_none_re = re.compile( diff --git a/glance/tests/functional/test_reload.py b/glance/tests/functional/test_reload.py index 62d51a2df5..710b030c33 100644 --- a/glance/tests/functional/test_reload.py +++ b/glance/tests/functional/test_reload.py @@ -31,7 +31,7 @@ TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), def set_config_value(filepath, key, value): """Set 'key = value' in config file""" replacement_line = '%s = %s\n' % (key, value) - match = re.compile('^%s\s+=' % key).match + match = re.compile(r'^%s\s+=' % key).match with open(filepath, 'r+') as f: lines = f.readlines() f.seek(0, 0)