summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2012-12-29 00:58:30 +0100
committerFlorent Xicluna <florent.xicluna@gmail.com>2013-01-18 23:10:25 +0100
commite5ecda868b2695f16beebf15e75a2810feae2a42 (patch)
tree64e601f7597be986ea64159f470f72102e49f3d7
parent8e4593319677c345b0dd8c415c39717c510d8878 (diff)
downloadpep8-e5ecda868b2695f16beebf15e75a2810feae2a42.tar.gz
Honor the # noqa in addition to # nopep8
-rw-r--r--CHANGES.txt2
-rwxr-xr-xpep8.py8
2 files changed, 8 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 301a013..73acb2b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,6 +9,8 @@ Changelog
* Report E703 instead of E702 for the trailing semicolon. (Issue #117)
+* Honor ``# noqa`` in addition to ``# no pep8``. (Issue #149)
+
1.4 (2012-12-22)
----------------
diff --git a/pep8.py b/pep8.py
index b406b81..91dd469 100755
--- a/pep8.py
+++ b/pep8.py
@@ -217,7 +217,7 @@ def maximum_line_length(physical_line, max_line_length):
line = physical_line.rstrip()
length = len(line)
if length > max_line_length:
- if line.strip().lower().endswith('# nopep8'):
+ if noqa(line):
return
if hasattr(line, 'decode'): # Python 2
# The line could contain multi-byte characters
@@ -434,7 +434,7 @@ def continuation_line_indentation(logical_line, tokens, indent_level, verbose):
print(">>> " + tokens[0][4].rstrip())
for token_type, text, start, end, line in tokens:
- if line.strip().lower().endswith('# nopep8'):
+ if noqa(line):
continue
newline = row < start[0] - first_row
@@ -1102,6 +1102,10 @@ def mute_string(text):
return text[:start] + 'x' * (end - start) + text[end:]
+def noqa(line):
+ return line.strip().lower().endswith(('# noqa', '# nopep8'))
+
+
def parse_udiff(diff, patterns=None, parent='.'):
"""Return a dictionary of matching lines."""
# For each file of the diff, the entry key is the filename,