From 497f1db5d142ddb891504d2513d52c5f195c05ac Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Tue, 16 Dec 2014 20:51:07 +0100 Subject: Do not skip physical checks if the newline is escaped; issue #319 --- CHANGES.txt | 2 ++ pep8.py | 12 +++++------- testsuite/E50.py | 14 ++++++++++++++ testsuite/W19.py | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d53fb70..d0ae802 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -43,6 +43,8 @@ Bug fixes: * Fix false positive E711/E712/E713. (Issues #330 and #336) +* Do not skip physical checks if the newline is escaped. (Issue #319) + 1.5.7 (2014-05-29) ------------------ diff --git a/pep8.py b/pep8.py index bb46c22..914d7fd 100755 --- a/pep8.py +++ b/pep8.py @@ -1238,14 +1238,12 @@ def filename_match(filename, patterns, default=True): return any(fnmatch(filename, pattern) for pattern in patterns) +def _is_eol_token(token): + return token[0] in NEWLINE or token[4][token[3][1]:].lstrip() == '\\\n' if COMMENT_WITH_NL: - def _is_eol_token(token): - return (token[0] in NEWLINE or - (token[0] == tokenize.COMMENT and token[1] == token[4])) -else: - def _is_eol_token(token): - return token[0] in NEWLINE - + def _is_eol_token(token, _eol_token=_is_eol_token): + return _eol_token(token) or (token[0] == tokenize.COMMENT and + token[1] == token[4]) ############################################################################## # Framework to run all checks diff --git a/testsuite/E50.py b/testsuite/E50.py index 31ad6b9..f60f389 100644 --- a/testsuite/E50.py +++ b/testsuite/E50.py @@ -1,5 +1,19 @@ #: E501 a = '12345678901234567890123456789012345678901234567890123456789012345678901234567890' +#: E501 +a = '1234567890123456789012345678901234567890123456789012345678901234567890' or \ + 6 +#: E501 +a = 7 or \ + '1234567890123456789012345678901234567890123456789012345678901234567890' or \ + 6 +#: E501 E501 +a = 7 or \ + '1234567890123456789012345678901234567890123456789012345678901234567890' or \ + '1234567890123456789012345678901234567890123456789012345678901234567890' or \ + 6 +#: E501 +a = '1234567890123456789012345678901234567890123456789012345678901234567890' # \ #: E502 a = ('123456789012345678901234567890123456789012345678901234567890123456789' \ '01234567890') diff --git a/testsuite/W19.py b/testsuite/W19.py index edbb1f0..afdfb76 100644 --- a/testsuite/W19.py +++ b/testsuite/W19.py @@ -86,7 +86,7 @@ if (a == 2 or b == """abc def ghi jkl mno"""): return True -#: E101 W191 +#: W191:2:1 W191:3:1 E101:3:2 if length > options.max_line_length: return options.max_line_length, \ "E501 line too long (%d characters)" % length -- cgit v1.2.1