Add length checks for line lengths.

This commit is contained in:
Dave Halter
2017-07-02 20:17:55 +02:00
parent 3057d15a4d
commit d9ebb09e64
2 changed files with 11 additions and 3 deletions

View File

@@ -421,6 +421,13 @@ class PEP8Normalizer(Normalizer):
self._check_spacing(leaf, spacing)
self._analyse_non_prefix(leaf)
last_column = leaf.end_pos[1]
if last_column > self._config.max_characters:
self.add_issue(
501,
'Line too long (%s > %s characters)' % (last_column, self._config.max_characters),
leaf
)
# -------------------------------
# Finalizing. Updating the state.
@@ -622,6 +629,7 @@ class PEP8NormalizerConfig(NormalizerConfig):
self.hanging_indentation = hanging_indentation
self.closing_bracket_hanging_indentation = ''
self.break_after_binary = False
self.max_characters = 79
@PEP8NormalizerConfig.register_rule

View File

@@ -21,15 +21,15 @@
# 情 情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情
#
#: E501
# 80 narrow chars (Na)
#: E501
# 01 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 [80]
#
#: E501
# 78 narrow chars (Na) + 2 wide char (W)
#: E501
# 01 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8情情
#
#: E501
# 3 narrow chars (Na) + 77 wide chars (W)
#: E501
# 情 情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情
#