mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-15 00:47:11 +08:00
Some more fixes. Test run now with pytest -k 'not E12' under Python 3.5.
This commit is contained in:
@@ -70,7 +70,8 @@ class IndentationNode(object):
|
|||||||
|
|
||||||
|
|
||||||
class BracketNode(IndentationNode):
|
class BracketNode(IndentationNode):
|
||||||
def __init__(self, config, parent_indentation, leaf, parent):
|
def __init__(self, config, parent_indentation, leaf, parent,
|
||||||
|
in_suite_introducer=False):
|
||||||
self.leaf = leaf
|
self.leaf = leaf
|
||||||
|
|
||||||
next_leaf = leaf.get_next_leaf()
|
next_leaf = leaf.get_next_leaf()
|
||||||
@@ -97,6 +98,12 @@ class BracketNode(IndentationNode):
|
|||||||
self.indentation = ' ' * expected_end_indent
|
self.indentation = ' ' * expected_end_indent
|
||||||
self.bracket_indentation = self.indentation
|
self.bracket_indentation = self.indentation
|
||||||
self.type = IndentationTypes.VERTICAL_BRACKET
|
self.type = IndentationTypes.VERTICAL_BRACKET
|
||||||
|
|
||||||
|
if in_suite_introducer and parent.type == IndentationTypes.SUITE \
|
||||||
|
and self.indentation == parent_indentation + config.indentation:
|
||||||
|
self.indentation += config.indentation
|
||||||
|
# The closing bracket should have the same indentation.
|
||||||
|
self.bracket_indentation = self.indentation
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
|
|
||||||
@@ -346,6 +353,8 @@ 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
|
||||||
|
elif leaf.value == 'elif':
|
||||||
|
self._in_suite_introducer = True
|
||||||
|
|
||||||
if not self._new_statement:
|
if not self._new_statement:
|
||||||
self._reset_newlines(part, leaf)
|
self._reset_newlines(part, leaf)
|
||||||
@@ -477,13 +486,11 @@ class PEP8Normalizer(Normalizer):
|
|||||||
if not isinstance(n, BracketNode) or previous_leaf != n.leaf:
|
if not isinstance(n, BracketNode) or previous_leaf != n.leaf:
|
||||||
break
|
break
|
||||||
n = n.parent
|
n = n.parent
|
||||||
indentation = n.indentation
|
|
||||||
if self._in_suite_introducer and node.type == IndentationTypes.SUITE:
|
|
||||||
indentation += self._config.indentation
|
|
||||||
|
|
||||||
self._indentation_tos = BracketNode(
|
self._indentation_tos = BracketNode(
|
||||||
self._config, indentation, leaf,
|
self._config, n.indentation, leaf,
|
||||||
parent=self._indentation_tos
|
parent=self._indentation_tos,
|
||||||
|
in_suite_introducer=self._in_suite_introducer
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
assert node.type != IndentationTypes.IMPLICIT
|
assert node.type != IndentationTypes.IMPLICIT
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ if True:
|
|||||||
def example_issue254():
|
def example_issue254():
|
||||||
#:
|
#:
|
||||||
return [node.copy(
|
return [node.copy(
|
||||||
#: E121:12
|
#: E121:12
|
||||||
(
|
(
|
||||||
#: E121:16 E126+1:24 E126+2:24
|
#: E121:16 E126+1:24 E126+2:24
|
||||||
replacement
|
replacement
|
||||||
|
|||||||
Reference in New Issue
Block a user