From 03e1a7270314800eb33632f778401570e65345bd Mon Sep 17 00:00:00 2001 From: Robin Dapp Date: Mon, 13 May 2024 22:05:57 +0200 Subject: [PATCH] check_GNU_style: Use raw strings. This silences some warnings when using check_GNU_style. contrib/ChangeLog: * check_GNU_style_lib.py: Use raw strings for regexps. --- contrib/check_GNU_style_lib.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib/check_GNU_style_lib.py b/contrib/check_GNU_style_lib.py index f1a120fa8d3..6dbe4b53559 100755 --- a/contrib/check_GNU_style_lib.py +++ b/contrib/check_GNU_style_lib.py @@ -103,7 +103,7 @@ class SpacesCheck: class SpacesAndTabsMixedCheck: def __init__(self): - self.re = re.compile('\ \t') + self.re = re.compile(r'\ \t') def check(self, filename, lineno, line): stripped = line.lstrip() @@ -115,7 +115,7 @@ class SpacesAndTabsMixedCheck: class TrailingWhitespaceCheck: def __init__(self): - self.re = re.compile('(\s+)$') + self.re = re.compile(r'(\s+)$') def check(self, filename, lineno, line): assert(len(line) == 0 or line[-1] != '\n') @@ -128,7 +128,7 @@ class TrailingWhitespaceCheck: class SentenceSeparatorCheck: def __init__(self): - self.re = re.compile('\w\.(\s|\s{3,})\w') + self.re = re.compile(r'\w\.(\s|\s{3,})\w') def check(self, filename, lineno, line): m = self.re.search(line) @@ -140,7 +140,7 @@ class SentenceSeparatorCheck: class SentenceEndOfCommentCheck: def __init__(self): - self.re = re.compile('\w\.(\s{0,1}|\s{3,})\*/') + self.re = re.compile(r'\w\.(\s{0,1}|\s{3,})\*/') def check(self, filename, lineno, line): m = self.re.search(line) @@ -152,7 +152,7 @@ class SentenceEndOfCommentCheck: class SentenceDotEndCheck: def __init__(self): - self.re = re.compile('\w(\s*\*/)') + self.re = re.compile(r'\w(\s*\*/)') def check(self, filename, lineno, line): m = self.re.search(line) @@ -164,7 +164,7 @@ class SentenceDotEndCheck: class FunctionParenthesisCheck: # TODO: filter out GTY stuff def __init__(self): - self.re = re.compile('\w(\s{2,})?(\()') + self.re = re.compile(r'\w(\s{2,})?(\()') def check(self, filename, lineno, line): if '#define' in line: @@ -179,7 +179,7 @@ class FunctionParenthesisCheck: class SquareBracketCheck: def __init__(self): - self.re = re.compile('\w\s+(\[)') + self.re = re.compile(r'\w\s+(\[)') def check(self, filename, lineno, line): if filename.endswith('.md'): @@ -194,7 +194,7 @@ class SquareBracketCheck: class ClosingParenthesisCheck: def __init__(self): - self.re = re.compile('\S\s+(\))') + self.re = re.compile(r'\S\s+(\))') def check(self, filename, lineno, line): m = self.re.search(line) @@ -208,7 +208,7 @@ class BracesOnSeparateLineCheck: # This will give false positives for C99 compound literals. def __init__(self): - self.re = re.compile('(\)|else)\s*({)') + self.re = re.compile(r'(\)|else)\s*({)') def check(self, filename, lineno, line): m = self.re.search(line) @@ -219,7 +219,7 @@ class BracesOnSeparateLineCheck: class TrailinigOperatorCheck: def __init__(self): - regex = '^\s.*(([^a-zA-Z_]\*)|([-%<=&|^?])|([^*]/)|([^:][+]))$' + regex = r'^\s.*(([^a-zA-Z_]\*)|([-%<=&|^?])|([^*]/)|([^:][+]))$' self.re = re.compile(regex) def check(self, filename, lineno, line):