mirror of
https://github.com/davidhalter/parso.git
synced 2026-05-25 01:38:52 +08:00
Cleanup some backslash node stuff.
This commit is contained in:
@@ -117,7 +117,7 @@ class ImplicitNode(BracketNode):
|
|||||||
class BackslashNode(IndentationNode):
|
class BackslashNode(IndentationNode):
|
||||||
type = IndentationTypes.BACKSLASH
|
type = IndentationTypes.BACKSLASH
|
||||||
|
|
||||||
def __init__(self, config, parent_indentation, containing_leaf, parent=None):
|
def __init__(self, config, parent_indentation, containing_leaf, spacing, parent=None):
|
||||||
from parso.python.tree import search_ancestor
|
from parso.python.tree import search_ancestor
|
||||||
expr_stmt = search_ancestor(containing_leaf, 'expr_stmt')
|
expr_stmt = search_ancestor(containing_leaf, 'expr_stmt')
|
||||||
if expr_stmt is not None:
|
if expr_stmt is not None:
|
||||||
@@ -127,10 +127,16 @@ class BackslashNode(IndentationNode):
|
|||||||
# TODO unite with the code of BracketNode
|
# TODO unite with the code of BracketNode
|
||||||
self.indentation = None
|
self.indentation = None
|
||||||
else:
|
else:
|
||||||
# +1 because there is a space.
|
# If the backslash follows the equals, use normal indentation
|
||||||
self.indentation = ' ' * (equals.end_pos[1] + 1)
|
# otherwise it should align with the equals.
|
||||||
|
if equals.end_pos == spacing.start_pos:
|
||||||
|
self.indentation = parent_indentation + config.indentation
|
||||||
|
else:
|
||||||
|
# +1 because there is a space.
|
||||||
|
self.indentation = ' ' * (equals.end_pos[1] + 1)
|
||||||
else:
|
else:
|
||||||
self.bracket_indentation = self.indentation = parent_indentation + config.indentation
|
self.indentation = parent_indentation + config.indentation
|
||||||
|
self.bracket_indentation = self.indentation
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
|
|
||||||
@@ -370,8 +376,6 @@ class PEP8Normalizer(Normalizer):
|
|||||||
|
|
||||||
|
|
||||||
self._newline_count += 1
|
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 type_ == 'backslash':
|
if type_ == 'backslash':
|
||||||
# TODO is this enough checking? What about ==?
|
# TODO is this enough checking? What about ==?
|
||||||
@@ -387,6 +391,7 @@ class PEP8Normalizer(Normalizer):
|
|||||||
self._config,
|
self._config,
|
||||||
indentation,
|
indentation,
|
||||||
leaf,
|
leaf,
|
||||||
|
spacing,
|
||||||
parent=self._indentation_tos
|
parent=self._indentation_tos
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ ddd = \
|
|||||||
#: E501:67 E225:21 E225:22
|
#: E501:67 E225:21 E225:22
|
||||||
very_long_identifiers=and_terrible_whitespace_habits(are_no_excuse+for_long_lines)
|
very_long_identifiers=and_terrible_whitespace_habits(are_no_excuse+for_long_lines)
|
||||||
#
|
#
|
||||||
#: E501
|
# TODO
|
||||||
|
##: E501
|
||||||
'''multiline string
|
'''multiline string
|
||||||
with a long long long long long long long long long long long long long long long long line
|
with a long long long long long long long long long long long long long long long long line
|
||||||
'''
|
'''
|
||||||
|
|||||||
Reference in New Issue
Block a user