diff options
author | Jimi Cullen <jimifhcullen@gmail.com> | 2018-04-03 12:24:38 +0100 |
---|---|---|
committer | Ian Stapleton Cordasco <graffatcolmingov@gmail.com> | 2018-04-03 06:24:38 -0500 |
commit | 9f225ac876b6340825770c9c665060dfc28300c6 (patch) | |
tree | 2daa8c08e95b50b9156c297a44d876ddc56c6ba7 | |
parent | 368e62cb6c57ff386b5a08659a5a9d2866b80a2f (diff) | |
download | pep8-9f225ac876b6340825770c9c665060dfc28300c6.tar.gz |
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.
-rwxr-xr-x | pycodestyle.py | 6 | ||||
-rw-r--r-- | testsuite/E50.py | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index 3e574c8..5371a67 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -260,7 +260,8 @@ def trailing_blank_lines(physical_line, lines, line_number, total_lines): @register_check -def maximum_line_length(physical_line, max_line_length, multiline, noqa): +def maximum_line_length(physical_line, max_line_length, multiline, + line_number, noqa): r"""Limit all lines to a maximum of 79 characters. 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): line = physical_line.rstrip() length = len(line) if length > max_line_length and not noqa: + # Special case: ignore long shebang lines. + if line_number == 1 and line.startswith('#!'): + return # Special case for long URLs in multi-line docstrings or comments, # but still report the error when the 72 first chars are whitespaces. chunks = line.split() diff --git a/testsuite/E50.py b/testsuite/E50.py index 189f416..6bca09b 100644 --- a/testsuite/E50.py +++ b/testsuite/E50.py @@ -121,3 +121,7 @@ import this #: E501 # This # almost_empty_line + +# +#: Okay +#!/reallylongpath/toexecutable --maybe --with --some ARGUMENTS TO DO WITH WHAT EXECUTABLE TO RUN |