diff --git a/parso/python/tree.py b/parso/python/tree.py index e342407..1437661 100644 --- a/parso/python/tree.py +++ b/parso/python/tree.py @@ -57,7 +57,11 @@ from parso.utils import split_lines _FLOW_CONTAINERS = set(['if_stmt', 'while_stmt', 'for_stmt', 'try_stmt', 'with_stmt', 'async_stmt', 'suite']) _RETURN_STMT_CONTAINERS = set(['suite', 'simple_stmt']) | _FLOW_CONTAINERS -_FUNC_CONTAINERS = set(['suite', 'simple_stmt', 'decorated']) | _FLOW_CONTAINERS + +_FUNC_CONTAINERS = set( + ['suite', 'simple_stmt', 'decorated', 'async_funcdef'] +) | _FLOW_CONTAINERS + _GET_DEFINITION_TYPES = set([ 'expr_stmt', 'sync_comp_for', 'with_stmt', 'for_stmt', 'import_name', 'import_from', 'param', 'del_stmt', diff --git a/test/test_parser_tree.py b/test/test_parser_tree.py index 3665f4e..7408479 100644 --- a/test/test_parser_tree.py +++ b/test/test_parser_tree.py @@ -222,3 +222,19 @@ def test_is_definition(code, name_index, is_definition, include_setitem): name = name.get_next_leaf() assert name.is_definition(include_setitem=include_setitem) == is_definition + + +def test_iter_funcdefs(): + code = dedent(''' + def normal(): ... + async def asyn(): ... + @dec + def dec_normal(): ... + @dec1 + @dec2 + async def dec_async(): ... + def broken + ''') + module = parse(code, version='3.8') + func_names = [f.name.value for f in module.iter_funcdefs()] + assert func_names == ['normal', 'asyn', 'dec_normal', 'dec_async']