Skip to content

Commit

Permalink
PEP8Bear: Add infinite line length
Browse files Browse the repository at this point in the history
Allows infinite line length when
max_line_length is set to 0.

Closes coala#2436
  • Loading branch information
newbazz committed Apr 17, 2018
1 parent 07304a4 commit c5a5e20
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bears/python/PEP8Bear.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import autopep8
import sys

from coalib.bearlib import deprecate_settings
from coalib.bearlib.spacing.SpacingHelper import SpacingHelper
Expand Down Expand Up @@ -31,13 +32,17 @@ def run(self, filename, file,
functionality of the code in any way.
:param max_line_length: Maximum number of characters for a line.
When set to 0 allows infinite line length.
:param indent_size: Number of spaces per indentation level.
:param pep_ignore: A list of errors/warnings to ignore.
:param pep_select: A list of errors/warnings to exclusively
apply.
:param local_pep8_config: Set to true if autopep8 should use a config
file as if run normally from this directory.
"""
if not max_line_length:
max_line_length = sys.maxsize

options = {'ignore': pep_ignore,
'select': pep_select,
'max_line_length': max_line_length,
Expand Down
5 changes: 5 additions & 0 deletions tests/python/PEP8BearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def test_line_length(self):
self.check_invalidity(self.uut,
['a = 1 + 1 + 1 + 1 + 1 + 1 + 1'])

def test_infinite_line_length(self):
valid_file = ['a =' + ' 1 +' * 100 + ' 1']
self.section.append(Setting('max_line_length', '0'))
self.check_validity(self.uut, valid_file)

def test_indent_level(self):
test_code = ['def func():\n',
' pass\n']
Expand Down

0 comments on commit c5a5e20

Please sign in to comment.