diff --git a/parso/python/normalizer.py b/parso/python/normalizer.py index 7925e8d..c18bac5 100644 --- a/parso/python/normalizer.py +++ b/parso/python/normalizer.py @@ -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 diff --git a/test/normalizer_issue_files/utf-8.py b/test/normalizer_issue_files/utf-8.py index e417cbc..73ea9a2 100644 --- a/test/normalizer_issue_files/utf-8.py +++ b/test/normalizer_issue_files/utf-8.py @@ -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 # 情 情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情情 #