Skip to content

Commit 77ad772

Browse files
authored
Merge pull request #808 from asottile/invalid_escape_sequence_offset
Fix line offset for 'invalid escape sequence'
2 parents c3d2cbd + 59f7604 commit 77ad772

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ All the tests should pass for all available interpreters, with the summary of::
6262

6363
congratulations :)
6464

65-
At this point you can create a pull request back to the official pycodestyles
65+
At this point you can create a pull request back to the official pycodestyle
6666
repository for review! For more information on how to make a pull request,
6767
GitHub has an excellent `guide`_.
6868

pycodestyle.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,7 @@ def python_3000_invalid_escape_sequence(logical_line, tokens):
15221522

15231523
for token_type, text, start, end, line in tokens:
15241524
if token_type == tokenize.STRING:
1525+
orig_start = start
15251526
quote = text[-3:] if text[-3:] in ('"""', "'''") else text[-1]
15261527
# Extract string modifiers (e.g. u or r)
15271528
quote_pos = text.index(quote)
@@ -1535,7 +1536,7 @@ def python_3000_invalid_escape_sequence(logical_line, tokens):
15351536
pos += 1
15361537
if string[pos] not in valid:
15371538
yield (
1538-
line.lstrip().find(text),
1539+
orig_start,
15391540
"W605 invalid escape sequence '\\%s'" %
15401541
string[pos],
15411542
)

testsuite/W60.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313
x = 0
1414
#: W604
1515
val = `1 + 2`
16-
#: W605
16+
#: W605:1:9
1717
regex = '\.png$'
18-
#: W605
18+
#: W605:1:9
1919
regex = '''
2020
\.png$
2121
'''
22+
#: W605:2:5
23+
f(
24+
'\_'
25+
)
2226
#: Okay
2327
regex = r'\.png$'
2428
regex = '\\.png$'

0 commit comments

Comments
 (0)