Skip to content

Commit 5ab3492

Browse files
committed
Fix E501 not detected in comments with Python 2.5
1 parent f01edd6 commit 5ab3492

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Changelog
77

88
* Fix false positive E121/E126 with multi-line strings. (Issue #265)
99

10+
* Fix E501 not detected in comments with Python 2.5.
11+
1012

1113
1.5.1 (2014-03-27)
1214
------------------

pep8.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,15 @@ def filename_match(filename, patterns, default=True):
11641164
return any(fnmatch(filename, pattern) for pattern in patterns)
11651165

11661166

1167+
if COMMENT_WITH_NL:
1168+
def _is_eol_token(token):
1169+
return (token[0] in (tokenize.NEWLINE, tokenize.NL) or
1170+
(token[0] == tokenize.COMMENT and token[1] == token[4]))
1171+
else:
1172+
def _is_eol_token(token):
1173+
return token[0] in (tokenize.NEWLINE, tokenize.NL)
1174+
1175+
11671176
##############################################################################
11681177
# Framework to run all checks
11691178
##############################################################################
@@ -1380,7 +1389,7 @@ def generate_tokens(self):
13801389
def maybe_check_physical(self, token):
13811390
"""If appropriate (based on token), check current physical line(s)."""
13821391
# Called after every token, but act only on end of line.
1383-
if token[0] in (tokenize.NEWLINE, tokenize.NL):
1392+
if _is_eol_token(token):
13841393
# Obviously, a newline token ends a single physical line.
13851394
self.check_physical(token[4])
13861395
elif token[0] == tokenize.STRING and '\n' in token[1]:

0 commit comments

Comments
 (0)