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.
This commit is contained in:
Robin Dapp 2024-05-13 22:05:57 +02:00
parent 68b0742a49
commit 03e1a72703

View File

@ -103,7 +103,7 @@ class SpacesCheck:
class SpacesAndTabsMixedCheck: class SpacesAndTabsMixedCheck:
def __init__(self): def __init__(self):
self.re = re.compile('\ \t') self.re = re.compile(r'\ \t')
def check(self, filename, lineno, line): def check(self, filename, lineno, line):
stripped = line.lstrip() stripped = line.lstrip()
@ -115,7 +115,7 @@ class SpacesAndTabsMixedCheck:
class TrailingWhitespaceCheck: class TrailingWhitespaceCheck:
def __init__(self): def __init__(self):
self.re = re.compile('(\s+)$') self.re = re.compile(r'(\s+)$')
def check(self, filename, lineno, line): def check(self, filename, lineno, line):
assert(len(line) == 0 or line[-1] != '\n') assert(len(line) == 0 or line[-1] != '\n')
@ -128,7 +128,7 @@ class TrailingWhitespaceCheck:
class SentenceSeparatorCheck: class SentenceSeparatorCheck:
def __init__(self): 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): def check(self, filename, lineno, line):
m = self.re.search(line) m = self.re.search(line)
@ -140,7 +140,7 @@ class SentenceSeparatorCheck:
class SentenceEndOfCommentCheck: class SentenceEndOfCommentCheck:
def __init__(self): 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): def check(self, filename, lineno, line):
m = self.re.search(line) m = self.re.search(line)
@ -152,7 +152,7 @@ class SentenceEndOfCommentCheck:
class SentenceDotEndCheck: class SentenceDotEndCheck:
def __init__(self): def __init__(self):
self.re = re.compile('\w(\s*\*/)') self.re = re.compile(r'\w(\s*\*/)')
def check(self, filename, lineno, line): def check(self, filename, lineno, line):
m = self.re.search(line) m = self.re.search(line)
@ -164,7 +164,7 @@ class SentenceDotEndCheck:
class FunctionParenthesisCheck: class FunctionParenthesisCheck:
# TODO: filter out GTY stuff # TODO: filter out GTY stuff
def __init__(self): def __init__(self):
self.re = re.compile('\w(\s{2,})?(\()') self.re = re.compile(r'\w(\s{2,})?(\()')
def check(self, filename, lineno, line): def check(self, filename, lineno, line):
if '#define' in line: if '#define' in line:
@ -179,7 +179,7 @@ class FunctionParenthesisCheck:
class SquareBracketCheck: class SquareBracketCheck:
def __init__(self): def __init__(self):
self.re = re.compile('\w\s+(\[)') self.re = re.compile(r'\w\s+(\[)')
def check(self, filename, lineno, line): def check(self, filename, lineno, line):
if filename.endswith('.md'): if filename.endswith('.md'):
@ -194,7 +194,7 @@ class SquareBracketCheck:
class ClosingParenthesisCheck: class ClosingParenthesisCheck:
def __init__(self): def __init__(self):
self.re = re.compile('\S\s+(\))') self.re = re.compile(r'\S\s+(\))')
def check(self, filename, lineno, line): def check(self, filename, lineno, line):
m = self.re.search(line) m = self.re.search(line)
@ -208,7 +208,7 @@ class BracesOnSeparateLineCheck:
# This will give false positives for C99 compound literals. # This will give false positives for C99 compound literals.
def __init__(self): def __init__(self):
self.re = re.compile('(\)|else)\s*({)') self.re = re.compile(r'(\)|else)\s*({)')
def check(self, filename, lineno, line): def check(self, filename, lineno, line):
m = self.re.search(line) m = self.re.search(line)
@ -219,7 +219,7 @@ class BracesOnSeparateLineCheck:
class TrailinigOperatorCheck: class TrailinigOperatorCheck:
def __init__(self): def __init__(self):
regex = '^\s.*(([^a-zA-Z_]\*)|([-%<=&|^?])|([^*]/)|([^:][+]))$' regex = r'^\s.*(([^a-zA-Z_]\*)|([-%<=&|^?])|([^*]/)|([^:][+]))$'
self.re = re.compile(regex) self.re = re.compile(regex)
def check(self, filename, lineno, line): def check(self, filename, lineno, line):