summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Stapleton Cordasco <graffatcolmingov@gmail.com>2018-10-24 19:19:13 -0500
committerGitHub <noreply@github.com>2018-10-24 19:19:13 -0500
commit77ad77278d04db396fcaddbc174b75bf3933a153 (patch)
tree34dcd2bceccf9c1fc2d0b3256f489f60e94af30c
parentc3d2cbd744236c3a41d1013c9dce2712dcc4eee0 (diff)
parent59f7604333b695677eaf23a61a4758969a2cee1c (diff)
downloadpep8-77ad77278d04db396fcaddbc174b75bf3933a153.tar.gz
Merge pull request #808 from asottile/invalid_escape_sequence_offset
Fix line offset for 'invalid escape sequence'
-rw-r--r--CONTRIBUTING.rst2
-rwxr-xr-xpycodestyle.py3
-rw-r--r--testsuite/W60.py8
3 files changed, 9 insertions, 4 deletions
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index f55c5e9..18b5a88 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -62,7 +62,7 @@ All the tests should pass for all available interpreters, with the summary of::
congratulations :)
-At this point you can create a pull request back to the official pycodestyles
+At this point you can create a pull request back to the official pycodestyle
repository for review! For more information on how to make a pull request,
GitHub has an excellent `guide`_.
diff --git a/pycodestyle.py b/pycodestyle.py
index 0d725d2..8b608b0 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -1522,6 +1522,7 @@ def python_3000_invalid_escape_sequence(logical_line, tokens):
for token_type, text, start, end, line in tokens:
if token_type == tokenize.STRING:
+ orig_start = start
quote = text[-3:] if text[-3:] in ('"""', "'''") else text[-1]
# Extract string modifiers (e.g. u or r)
quote_pos = text.index(quote)
@@ -1535,7 +1536,7 @@ def python_3000_invalid_escape_sequence(logical_line, tokens):
pos += 1
if string[pos] not in valid:
yield (
- line.lstrip().find(text),
+ orig_start,
"W605 invalid escape sequence '\\%s'" %
string[pos],
)
diff --git a/testsuite/W60.py b/testsuite/W60.py
index 030bec5..1b03099 100644
--- a/testsuite/W60.py
+++ b/testsuite/W60.py
@@ -13,12 +13,16 @@ if x <> 0:
x = 0
#: W604
val = `1 + 2`
-#: W605
+#: W605:1:9
regex = '\.png$'
-#: W605
+#: W605:1:9
regex = '''
\.png$
'''
+#: W605:2:5
+f(
+ '\_'
+)
#: Okay
regex = r'\.png$'
regex = '\\.png$'