4545 print(1)
4646"""
4747
48+ # 3 conditions, nested conditions are not counted.
49+ if_with_nested_conditions = """
50+ if (a is None or (func1(a) and b) or (func2(a) and c)):
51+ ...
52+ """
53+
4854# Real examples:
4955
5056complex_assignment = """
51- some = zero and first or (second and last) or default()
57+ some = zero and first or (second and last) or default() or c or d
5258"""
5359
5460complex_condition = """
55- if x == x1 and y == y1 and z == z1 or v == v1 or last():
61+ if x == x1 and y == y1 and z == z1 or v == v1 or last() or to_be() \
62+ or not_to_be():
5663 ...
5764"""
5865
66+ complex_list_comprehension = """
67+ def example(x, y):
68+ return [i for i in range(x) if i % 2 == 0 or i == y or i > 10 or \
69+ y < 4 or i != 0]
70+ """
71+
5972complex_while = """
60- while (x > x1 or y < y1) or (small(z) and v) or last():
73+ while (x > x1 or y < y1) or (small(z) and v) or first() or second() or last():
6174 ...
6275"""
6376
6477complex_match = """
6578match some:
66- case 1 if (x > x1 or y < y1) or (small(z) and v) or last():
79+ case 1 if (x > x1 or y < y1) or (small(z) and v) or first() or \
80+ second() or last():
6781 ...
6882"""
6983
7084complex_gen_exp = """
7185(
7286 ...
7387 for name in []
74- if (x > x1 or y < y1) or (small(z) and v) or last()
88+ if (x > x1 or y < y1) or (small(z) and v) or (b() and g()) or \
89+ second() or last()
7590)
7691"""
7792
89104 condition_with_inline_for ,
90105 condition_with_simple_inline_for ,
91106 while_with_condition ,
107+ if_with_nested_conditions ,
92108 ],
93109)
94110def test_module_condition_counts_normal (
@@ -111,6 +127,7 @@ def test_module_condition_counts_normal(
111127 [
112128 complex_assignment ,
113129 complex_condition ,
130+ complex_list_comprehension ,
114131 complex_while ,
115132 complex_match ,
116133 complex_gen_exp ,
@@ -138,6 +155,7 @@ def test_module_condition_real_config(
138155 [
139156 complex_assignment ,
140157 complex_condition ,
158+ complex_list_comprehension ,
141159 complex_while ,
142160 complex_match ,
143161 complex_gen_exp ,
0 commit comments