|
5 | 5 |
|
6 | 6 | def iterate_over_expressions(node: ast.AST) -> Iterable[ast.AST]: |
7 | 7 | additionals_subnodes_info: List[Tuple[Tuple, Callable]] = [ |
8 | | - ((ast.If, ast.While), lambda n: n.test), |
9 | | - ((ast.For, ), lambda n: n.iter), |
| 8 | + ((ast.If, ast.While), lambda n: [n.test]), |
| 9 | + ((ast.For, ), lambda n: [n.iter]), |
| 10 | + ((ast.With, ast.AsyncWith), lambda n: [s.context_expr for s in n.items]), |
10 | 11 | ] |
11 | 12 | nodes_with_subnodes = ( |
12 | 13 | ast.FunctionDef, ast.AsyncFunctionDef, |
13 | 14 | ast.If, ast.For, ast.Module, |
14 | | - ast.ClassDef, ast.Try, ast.With, ast.While, |
| 15 | + ast.ClassDef, ast.Try, ast.With, ast.AsyncWith, |
| 16 | + ast.While, |
15 | 17 | ) |
16 | 18 | for bases, subnodes_getter in additionals_subnodes_info: |
17 | 19 | if isinstance(node, bases): |
18 | | - yield subnodes_getter(node) |
| 20 | + for subitem in subnodes_getter(node): |
| 21 | + yield subitem |
19 | 22 | nodes_to_iter = ( |
20 | 23 | _get_try_node_children(node) |
21 | 24 | if isinstance(node, ast.Try) |
|
0 commit comments