Skip to content

Commit 9f225ac

Browse files
jfhcsigmavirus24
authored andcommitted
Ignore length of shebang line (#736)
* Add special case to maximum_line_length to ignore long shebang lines. * Add test for ignoring long shebang lines. * Clean up shebang line check.
1 parent 368e62c commit 9f225ac

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pycodestyle.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ def trailing_blank_lines(physical_line, lines, line_number, total_lines):
260260

261261

262262
@register_check
263-
def maximum_line_length(physical_line, max_line_length, multiline, noqa):
263+
def maximum_line_length(physical_line, max_line_length, multiline,
264+
line_number, noqa):
264265
r"""Limit all lines to a maximum of 79 characters.
265266
266267
There are still many devices around that are limited to 80 character
@@ -275,6 +276,9 @@ def maximum_line_length(physical_line, max_line_length, multiline, noqa):
275276
line = physical_line.rstrip()
276277
length = len(line)
277278
if length > max_line_length and not noqa:
279+
# Special case: ignore long shebang lines.
280+
if line_number == 1 and line.startswith('#!'):
281+
return
278282
# Special case for long URLs in multi-line docstrings or comments,
279283
# but still report the error when the 72 first chars are whitespaces.
280284
chunks = line.split()

testsuite/E50.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,7 @@ def foo():
121121
#: E501
122122
# This
123123
# almost_empty_line
124+
125+
#
126+
#: Okay
127+
#!/reallylongpath/toexecutable --maybe --with --some ARGUMENTS TO DO WITH WHAT EXECUTABLE TO RUN

0 commit comments

Comments
 (0)