Better handling for E291 after newline (trailing whitespace).

This commit is contained in:
Dave Halter
2017-07-02 21:18:35 +02:00
parent d9ebb09e64
commit 4d390742cd

View File

@@ -381,7 +381,10 @@ class PEP8Normalizer(Normalizer):
n = n.parent n = n.parent
if self._new_statement: if self._new_statement:
if indentation != should_be_indentation: if leaf.type == 'newline':
if indentation:
self.add_issue(291, 'Trailing whitespace', spacing)
elif indentation != should_be_indentation:
s = '%s %s' % (len(self._config.indentation), self._indentation_type) s = '%s %s' % (len(self._config.indentation), self._indentation_type)
self.add_issue(111, 'Indentation is not a multiple of ' + s, leaf) self.add_issue(111, 'Indentation is not a multiple of ' + s, leaf)
else: else:
@@ -538,7 +541,6 @@ class PEP8Normalizer(Normalizer):
else: else:
message_225 = 'Missing whitespace between tokens' message_225 = 'Missing whitespace between tokens'
add_not_spaces(225, message_225, spacing) add_not_spaces(225, message_225, spacing)
#print('x', leaf.start_pos, leaf, prev)
elif type_ == 'keyword' or prev.type == 'keyword': elif type_ == 'keyword' or prev.type == 'keyword':
add_not_spaces(275, 'Missing whitespace around keyword', spacing) add_not_spaces(275, 'Missing whitespace around keyword', spacing)
else: else:
@@ -549,7 +551,6 @@ class PEP8Normalizer(Normalizer):
self.add_issue(229, message, spacing) self.add_issue(229, message, spacing)
if spaces and leaf not in _ALLOW_SPACE and prev not in _ALLOW_SPACE: if spaces and leaf not in _ALLOW_SPACE and prev not in _ALLOW_SPACE:
#print(leaf, prev)
self.add_issue(225, message_225, spacing) self.add_issue(225, message_225, spacing)
def _analyse_non_prefix(self, leaf): def _analyse_non_prefix(self, leaf):