mirror of
https://github.com/davidhalter/parso.git
synced 2026-01-19 17:43:07 +08:00
Don't use invalid escape sequences in regex, see https://github.com/davidhalter/jedi-vim/issues/843
This commit is contained in:
@@ -391,11 +391,11 @@ class PEP8Normalizer(ErrorFinder):
|
||||
if value.lstrip('#'):
|
||||
self.add_issue(part, 266, "Too many leading '#' for block comment.")
|
||||
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)):
|
||||
self.add_issue(part, 265, "Block comment should start with '# '")
|
||||
else:
|
||||
if not re.match('#:? [^ ]', value):
|
||||
if not re.match(r'#:? [^ ]', value):
|
||||
self.add_issue(part, 262, "Inline comment should start with '# '")
|
||||
|
||||
self._reset_newlines(spacing, leaf, is_comment=True)
|
||||
@@ -677,7 +677,7 @@ class PEP8Normalizer(ErrorFinder):
|
||||
elif typ == 'string':
|
||||
# Checking multiline strings
|
||||
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)
|
||||
# TODO check multiline indentation.
|
||||
elif typ == 'endmarker':
|
||||
|
||||
@@ -252,7 +252,7 @@ class String(Literal):
|
||||
|
||||
@property
|
||||
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):
|
||||
match = re.search(
|
||||
|
||||
@@ -45,7 +45,7 @@ def split_lines(string, keepends=False):
|
||||
lst.append('')
|
||||
return lst
|
||||
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'):
|
||||
|
||||
Reference in New Issue
Block a user