Don't use invalid escape sequences in regex, see https://github.com/davidhalter/jedi-vim/issues/843

This commit is contained in:
Dave Halter
2018-07-12 08:53:48 +02:00
parent e6bc924fba
commit 7064ecf3fb
3 changed files with 5 additions and 5 deletions

View File

@@ -391,11 +391,11 @@ class PEP8Normalizer(ErrorFinder):
if value.lstrip('#'): if value.lstrip('#'):
self.add_issue(part, 266, "Too many leading '#' for block comment.") self.add_issue(part, 266, "Too many leading '#' for block comment.")
elif self._on_newline: elif self._on_newline:
if not re.match('#:? ', value) and not value == '#' \ if not re.match(r'#:? ', value) and not value == '#' \
and not (value.startswith('#!') and part.start_pos == (1, 0)): and not (value.startswith('#!') and part.start_pos == (1, 0)):
self.add_issue(part, 265, "Block comment should start with '# '") self.add_issue(part, 265, "Block comment should start with '# '")
else: else:
if not re.match('#:? [^ ]', value): if not re.match(r'#:? [^ ]', value):
self.add_issue(part, 262, "Inline comment should start with '# '") self.add_issue(part, 262, "Inline comment should start with '# '")
self._reset_newlines(spacing, leaf, is_comment=True) self._reset_newlines(spacing, leaf, is_comment=True)
@@ -677,7 +677,7 @@ class PEP8Normalizer(ErrorFinder):
elif typ == 'string': elif typ == 'string':
# Checking multiline strings # Checking multiline strings
for i, line in enumerate(leaf.value.splitlines()[1:]): for i, line in enumerate(leaf.value.splitlines()[1:]):
indentation = re.match('[ \t]*', line).group(0) indentation = re.match(r'[ \t]*', line).group(0)
start_pos = leaf.line + i, len(indentation) start_pos = leaf.line + i, len(indentation)
# TODO check multiline indentation. # TODO check multiline indentation.
elif typ == 'endmarker': elif typ == 'endmarker':

View File

@@ -252,7 +252,7 @@ class String(Literal):
@property @property
def string_prefix(self): def string_prefix(self):
return re.match('\w*(?=[\'"])', self.value).group(0) return re.match(r'\w*(?=[\'"])', self.value).group(0)
def _get_payload(self): def _get_payload(self):
match = re.search( match = re.search(

View File

@@ -45,7 +45,7 @@ def split_lines(string, keepends=False):
lst.append('') lst.append('')
return lst return lst
else: else:
return re.split('\n|\r\n', string) return re.split(r'\n|\r\n', string)
def python_bytes_to_unicode(source, encoding='utf-8', errors='strict'): def python_bytes_to_unicode(source, encoding='utf-8', errors='strict'):