New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the position pointed out by W605 #747

Merged
merged 1 commit into from Apr 12, 2018

Conversation

Projects
None yet
3 participants
@hhatto
Copy link
Contributor

hhatto commented Apr 12, 2018

test environment:

$ python -V
Python 3.6.5
$ pycodestyle --version
2.4.0

input file:

# target.py
regex = ('hello', "\.png$")


def main():
    regex = ('hello', "\.png$")

before:

target.py:1:2: W605 invalid escape sequence '\.'
regex = ('hello', "\.png$")
 ^
    Invalid escape sequences are deprecated in Python 3.6.

    Okay: regex = r'\.png$'
    W605: regex = '\.png$'
target.py:5:6: W605 invalid escape sequence '\.'
    regex = ('hello', "\.png$")
     ^
    Invalid escape sequences are deprecated in Python 3.6.

    Okay: regex = r'\.png$'
    W605: regex = '\.png$'

after:

target.py:1:19: W605 invalid escape sequence '\.'
regex = ('hello', "\.png$")
                  ^
    Invalid escape sequences are deprecated in Python 3.6.

    Okay: regex = r'\.png$'
    W605: regex = '\.png$'
target.py:5:23: W605 invalid escape sequence '\.'
    regex = ('hello', "\.png$")
                      ^
    Invalid escape sequences are deprecated in Python 3.6.

    Okay: regex = r'\.png$'
    W605: regex = '\.png$'

Thanks.

@@ -1524,7 +1524,7 @@ def python_3000_invalid_escape_sequence(logical_line, tokens):
pos += 1
if string[pos] not in valid:
yield (
pos,
line.lstrip().find(text),

This comment has been minimized.

@hoylemd

hoylemd Apr 12, 2018

Maybe I'm missing something, but wouldn't lstrip subtract the indentation from the index of text?

This comment has been minimized.

@hhatto

hhatto Apr 12, 2018

Contributor

In the following sections, pos is derived from logical_line. I followed this and I have removed indentation.
https://github.com/PyCQA/pycodestyle/blob/master/pycodestyle.py#L1438
https://github.com/PyCQA/pycodestyle/blob/master/pycodestyle.py#L1452

This comment has been minimized.

@hoylemd

hoylemd Apr 12, 2018

Ah! that makes sense. Thanks for explaining.

@sigmavirus24

This comment has been minimized.

Copy link
Member

sigmavirus24 commented Apr 12, 2018

Closing and reopening to trigger a new build against master

@sigmavirus24 sigmavirus24 reopened this Apr 12, 2018

@sigmavirus24 sigmavirus24 merged commit d8f10a9 into PyCQA:master Apr 12, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sigmavirus24

This comment has been minimized.

Copy link
Member

sigmavirus24 commented Apr 12, 2018

Thanks @hhatto!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment