mirror of
https://github.com/davidhalter/parso.git
synced 2026-03-01 21:07:28 +08:00
Fix all E303.
This commit is contained in:
@@ -278,6 +278,10 @@ class PEP8Normalizer(Normalizer):
|
|||||||
if leaf.value == ':' and leaf.parent.type in _SUITE_INTRODUCERS:
|
if leaf.value == ':' and leaf.parent.type in _SUITE_INTRODUCERS:
|
||||||
self._in_suite_introducer = False
|
self._in_suite_introducer = False
|
||||||
|
|
||||||
|
if not self._new_statement:
|
||||||
|
self._newline_count = 0
|
||||||
|
|
||||||
|
|
||||||
return x
|
return x
|
||||||
|
|
||||||
def _old_normalize(self, leaf, spacing):
|
def _old_normalize(self, leaf, spacing):
|
||||||
@@ -288,6 +292,18 @@ class PEP8Normalizer(Normalizer):
|
|||||||
|
|
||||||
node = self._indentation_tos
|
node = self._indentation_tos
|
||||||
|
|
||||||
|
if leaf.type == 'comment':
|
||||||
|
self._newline_count = 0
|
||||||
|
elif leaf.type == 'newline':
|
||||||
|
suite_node = node.get_latest_suite_node()
|
||||||
|
max_lines = 3 if suite_node.parent is None else 2
|
||||||
|
if self._newline_count >= max_lines:
|
||||||
|
self.add_issue(303, "Too many blank lines (%s)" % self._newline_count, leaf)
|
||||||
|
|
||||||
|
self._newline_count += 1
|
||||||
|
#if | E302 | expected 2 blank lines, found 0
|
||||||
|
# self.add_issue(302, "Too many blank lines (%s)" % self._newline_count, leaf)
|
||||||
|
|
||||||
if leaf.type == 'backslash':
|
if leaf.type == 'backslash':
|
||||||
# TODO is this enough checking? What about ==?
|
# TODO is this enough checking? What about ==?
|
||||||
if node.type != IndentationTypes.BACKSLASH:
|
if node.type != IndentationTypes.BACKSLASH:
|
||||||
|
|||||||
Reference in New Issue
Block a user