Skip to content

Commit 7fa71af

Browse files
committed
Update maximum_line_length to use Checker.noqa
This also updates the Checker to update it's state for physical lines as well as logical lines. This allows maximum_line_length to rely on Checker state for its noqa check. Closes #538
1 parent 6cb59d6 commit 7fa71af

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

pycodestyle.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def trailing_blank_lines(physical_line, lines, line_number, total_lines):
199199
return len(physical_line), "W292 no newline at end of file"
200200

201201

202-
def maximum_line_length(physical_line, max_line_length, multiline):
202+
def maximum_line_length(physical_line, max_line_length, multiline, noqa):
203203
r"""Limit all lines to a maximum of 79 characters.
204204
205205
There are still many devices around that are limited to 80 character
@@ -213,7 +213,7 @@ def maximum_line_length(physical_line, max_line_length, multiline):
213213
"""
214214
line = physical_line.rstrip()
215215
length = len(line)
216-
if length > max_line_length and not noqa(line):
216+
if length > max_line_length and not noqa:
217217
# Special case for long URLs in multi-line docstrings or comments,
218218
# but still report the error when the 72 first chars are whitespaces.
219219
chunks = line.split()
@@ -1500,6 +1500,7 @@ def __init__(self, filename=None, lines=None,
15001500
self.lines[0] = self.lines[0][3:]
15011501
self.report = report or options.report
15021502
self.report_error = self.report.error
1503+
self.noqa = False
15031504

15041505
def report_invalid_syntax(self):
15051506
"""Check if the syntax is valid."""
@@ -1634,6 +1635,7 @@ def generate_tokens(self):
16341635
for token in tokengen:
16351636
if token[2][0] > self.total_lines:
16361637
return
1638+
self.noqa = token[4] and noqa(token[4])
16371639
self.maybe_check_physical(token)
16381640
yield token
16391641
except (SyntaxError, tokenize.TokenError):

0 commit comments

Comments
 (0)