Skip to content

Commit 2aad586

Browse files
authored
Merge pull request #3 from Stafil0/master
Added await support
2 parents b0fb4de + 0296a60 commit 2aad586

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

flake8_expression_complexity/utils/complexity.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def get_complexity_increase_for_node_type(node_type_sid: str) -> float:
2424
'assign': 1,
2525
'featured_assign': 1,
2626
'call': .5,
27+
'await': .5,
2728
'sized': 1,
2829
'dict': 1,
2930
'dict_comprehension': 1,
@@ -59,6 +60,7 @@ def get_expression_part_info(node: ast.AST) -> Mapping[str, Any]:
5960
(ast.Assign, 'assign'),
6061
((ast.AugAssign, ast.AnnAssign), 'featured_assign'),
6162
(ast.Call, 'call'),
63+
(ast.Await, 'await'),
6264
((ast.List, ast.Set, ast.Tuple), 'sized'),
6365
(ast.Dict, 'dict'),
6466
(ast.DictComp, 'dict_comprehension'),
@@ -108,6 +110,7 @@ def _get_sub_nodes(node: Any, node_type_sid: str) -> List[ast.AST]:
108110
'assign': lambda n: node.targets + [node.value],
109111
'featured_assign': lambda n: [n.target, n.value],
110112
'call': lambda n: node.args + [n.func],
113+
'await': lambda n: [node.value],
111114
'sized': lambda n: node.elts,
112115
'dict': lambda n: itertools.chain(node.keys, node.values),
113116
'dict_comprehension': lambda n: node.generators + [n.key, n.value],

tests/test_files/long_expressions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ async def foo():
3636
> today - datetime.timedelta(days=10)
3737
)
3838
):
39+
await bar()
3940
pass
4041

4142

43+
async def bar():
44+
return 'bar'
45+
46+
4247
weird_container = []
4348
sublist = weird_container[10:datetime.datetime.today(), None]

0 commit comments

Comments
 (0)