mirror of
https://github.com/davidhalter/parso.git
synced 2026-02-15 22:52:04 +08:00
Fix some issues with async funcs
This commit is contained in:
@@ -15,6 +15,7 @@ from parso.python.parser import Parser
|
||||
from parso.python.tree import EndMarker, PythonErrorLeaf
|
||||
from parso.python.tokenize import PythonToken
|
||||
from parso.python.token import PythonTokenTypes
|
||||
from parso.tree import search_ancestor
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
DEBUG_DIFF_PARSER = False
|
||||
@@ -164,6 +165,12 @@ def _func_or_class_has_suite(node):
|
||||
return node.type in ('classdef', 'funcdef') and node.children[-1].type == 'suite'
|
||||
|
||||
|
||||
def _get_suite_func_or_class_parent(node):
|
||||
while node.parent.type in ('funcdef', 'classdef', 'async_stmt', 'async_funcdef', 'decorated'):
|
||||
node = node.parent
|
||||
return node
|
||||
|
||||
|
||||
def _suite_or_file_input_is_valid(pgen_grammar, stack):
|
||||
if not _flows_finished(pgen_grammar, stack):
|
||||
return False
|
||||
@@ -467,7 +474,7 @@ class _NodesTreeNode(object):
|
||||
if self.tree_node.type == 'file_input':
|
||||
self.indentation = 0
|
||||
else:
|
||||
self.indentation = self.tree_node.parent.start_pos[-1]
|
||||
self.indentation = _get_suite_func_or_class_parent(self.tree_node).start_pos[1]
|
||||
|
||||
def finish(self):
|
||||
children = []
|
||||
|
||||
Reference in New Issue
Block a user