[d-feet/enable-gitlab-ci: 1/3] settings: use r'' strings for regexps



commit 45a1146e1122b376ddac312687e8e27d4e0a8076
Author: Will Thompson <will willthompson co uk>
Date:   Wed Sep 19 11:15:02 2018 +0100

    settings: use r'' strings for regexps
    
    ../../src/dfeet/settings.py:22:17: W605 invalid escape sequence '\.'
    ../../src/dfeet/settings.py:23:6: W605 invalid escape sequence '\s'
    ../../src/dfeet/settings.py:28:10: W605 invalid escape sequence '\s'
    ../../src/dfeet/settings.py:29:12: W605 invalid escape sequence '\('

 src/dfeet/settings.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/dfeet/settings.py b/src/dfeet/settings.py
index ffd5f29..ca61bbd 100644
--- a/src/dfeet/settings.py
+++ b/src/dfeet/settings.py
@@ -18,15 +18,16 @@ class ConfigTokenizer():
     COMMA = re.compile(",")
     FALLTHROUGH = re.compile('(?:[^,.])+')
     # FIXME: String re does not ignore escaped quotes (e.g. \") correctly
-    STRING = re.compile('"((?:[^\\"]|\\.)*)"' + "|'((?:[^\\']|\\.)*)'")
-    NUMBER = re.compile('[+-]?[0-9]*\.?[0-9]+')
-    WHITESPACE = re.compile('\s')
+    STRING = re.compile(r'"((?:[^\"]|\.)*)"' +
+                        r"|'((?:[^\']|\.)*)'")
+    NUMBER = re.compile(r'[+-]?[0-9]*\.?[0-9]+')
+    WHITESPACE = re.compile(r'\s')
 
     _parse_order = [STRING, NUMBER, WHITESPACE, COMMA, FALLTHROUGH]
 
     class Match():
-        ENDWHITESPACE = re.compile('\s$')
-        UNESCAPE = re.compile('\\\(.)')
+        ENDWHITESPACE = re.compile(r'\s$')
+        UNESCAPE = re.compile(r'\\\(.)')
 
         def __init__(self, match, regex):
             self.match = match


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]