Last active
December 14, 2015 03:58
-
-
Save florentx/5024445 to your computer and use it in GitHub Desktop.
Workaround feature https://github.com/jcrocholl/pep8/issues/159
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
import re | |
import pep8 | |
# This is a very long line - 79 chars --------------------------------123456789 | |
# This is a very [[with-poporg][long line]] - 79 chars --------------------------------123456789 | |
# This is a very [[with-poporg][long line]] - 80 chars --------------------------------1234567890 | |
def maximum_line_length(physical_line, max_line_length): | |
line = physical_line.rstrip() | |
length = len(line) | |
if length > max_line_length: | |
if pep8.noqa(line): | |
return | |
if hasattr(line, 'decode'): # Python 2 | |
# The line could contain multi-byte characters | |
try: | |
length = len(line.decode('utf-8')) | |
except UnicodeError: | |
pass | |
if length > max_line_length: | |
line = re.sub(r'\[\[[^]]*\]\[([^]]*)\]\]', r'\1', line) | |
length = len(line) | |
if length > max_line_length: | |
return (max_line_length, "E501 line too long " | |
"(%d > %d characters)" % (length, max_line_length)) | |
del pep8._checks['physical_line'][pep8.maximum_line_length] | |
pep8.register_check(maximum_line_length, ['E501']) | |
if __name__ == '__main__': | |
pep8._main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment