Skip to content

Commit b0fb4de

Browse files
author
Илья Лебедев
committed
fix #2: now works with async defs
1 parent 73914b6 commit b0fb4de

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.0.3'
1+
__version__ = '0.0.4'

flake8_expression_complexity/utils/ast.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ def iterate_over_expressions(node: ast.AST) -> Iterable[ast.AST]:
99
((ast.For, ), lambda n: n.iter),
1010
]
1111
nodes_with_subnodes = (
12-
ast.FunctionDef, ast.If, ast.For, ast.Module,
12+
ast.FunctionDef, ast.AsyncFunctionDef,
13+
ast.If, ast.For, ast.Module,
1314
ast.ClassDef, ast.Try, ast.With, ast.While,
1415
)
1516
for bases, subnodes_getter in additionals_subnodes_info:

tests/test_files/long_expressions.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ class Sum:
2323
pass
2424

2525

26-
if (
27-
(user and user.is_authorized)
28-
and user.subscriptions.filter(start_date__lt=today, end_date__gt=today).exists()
29-
and (
30-
user.total_credits_added
31-
- Check.objects.filter(user=user).aggregate(Sum('price'))['check__sum']
32-
)
33-
and UserAction.objects.filter(user=user).last().datetime > today - datetime.timedelta(days=10)
34-
):
35-
pass
26+
async def foo():
27+
if (
28+
(user and user.is_authorized)
29+
and user.subscriptions.filter(start_date__lt=today, end_date__gt=today).exists()
30+
and (
31+
user.total_credits_added
32+
- Check.objects.filter(user=user).aggregate(Sum('price'))['check__sum']
33+
)
34+
and (
35+
UserAction.objects.filter(user=user).last().datetime
36+
> today - datetime.timedelta(days=10)
37+
)
38+
):
39+
pass
3640

3741

3842
weird_container = []

0 commit comments

Comments
 (0)