Skip to content

Commit

Permalink
add max-line-length option
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Koss authored and treyhunner committed Jan 26, 2011
1 parent ae63094 commit f68c3ce
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,17 @@ def maximum_line_length(physical_line):
"""
line = physical_line.rstrip()
length = len(line)
if length > MAX_LINE_LENGTH:
if length > options.max_line_length:
try:
# The line could contain multi-byte characters
if not hasattr(line, 'decode'): # Python 3
line = line.encode('latin-1')
length = len(line.decode('utf-8'))
except UnicodeDecodeError:
pass
if length > MAX_LINE_LENGTH:
return MAX_LINE_LENGTH, "E501 line too long (%d characters)" % length
if length > options.max_line_length:
return options.max_line_length, \
"E501 line too long (%d characters)" % length


##############################################################################
Expand Down Expand Up @@ -1289,6 +1290,10 @@ def process_options(arglist=None):
help="measure processing speed")
parser.add_option('--testsuite', metavar='dir',
help="run regression tests from dir")
parser.add_option('--max-line-length', type='int', metavar='n',
default=MAX_LINE_LENGTH,
help="set to a higher value to relax pep8 "
"line length restictions")
parser.add_option('--doctest', action='store_true',
help="run doctest on myself")
options, args = parser.parse_args(arglist)
Expand Down

0 comments on commit f68c3ce

Please sign in to comment.