Debian Codegraph @

tests/data/cases/preview_remove_multiline_lone_list_item_parens.py

raw
1 # flags: --unstable
2 items = [(x for x in [1])]
3
4 items = [
5 (
6 {"key1": "val1", "key2": "val2", "key3": "val3"}
7 if some_var == "long strings"
8 else {"key": "val"}
9 )
10 ]
11 items = [
12 (
13 {"key1": "val1", "key2": "val2"}
14 if some_var == ""
15 else {"key": "val"}
16 )
17 ]
18 items = [
19 (
20 "123456890123457890123468901234567890"
21 if some_var == "long strings"
22 else "123467890123467890"
23 )
24 ]
25 items = [
26 (
27 {"key1": "val1", "key2": "val2", "key3": "val3"}
28 and some_var == "long strings"
29 and {"key": "val"}
30 )
31 ]
32 items = [
33 (
34 "123456890123457890123468901234567890"
35 and some_var == "long strings"
36 and "123467890123467890"
37 )
38 ]
39 items = [
40 (
41 long_variable_name
42 and even_longer_variable_name
43 and yet_another_very_long_variable_name
44 )
45 ]
46
47 # Shouldn't remove trailing commas
48 items = [
49 (
50 {"key1": "val1", "key2": "val2", "key3": "val3"}
51 if some_var == "long strings"
52 else {"key": "val"}
53 ),
54 ]
55 items = [
56 (
57 {"key1": "val1", "key2": "val2", "key3": "val3"}
58 and some_var == "long strings"
59 and {"key": "val"}
60 ),
61 ]
62 items = [
63 (
64 "123456890123457890123468901234567890"
65 and some_var == "long strings"
66 and "123467890123467890"
67 ),
68 ]
69 items = [
70 (
71 long_variable_name
72 and even_longer_variable_name
73 and yet_another_very_long_variable_name
74 ),
75 ]
76
77 # Shouldn't add parentheses
78 items = [
79 {"key1": "val1", "key2": "val2", "key3": "val3"}
80 if some_var == "long strings"
81 else {"key": "val"}
82 ]
83 items = [{"key1": "val1", "key2": "val2"} if some_var == "" else {"key": "val"}]
84
85 # Shouldn't crash with comments
86 items = [
87 ( # comment
88 {"key1": "val1", "key2": "val2", "key3": "val3"}
89 if some_var == "long strings"
90 else {"key": "val"}
91 )
92 ]
93 items = [
94 (
95 {"key1": "val1", "key2": "val2", "key3": "val3"}
96 if some_var == "long strings"
97 else {"key": "val"}
98 ) # comment
99 ]
100
101 items = [ # comment
102 (
103 {"key1": "val1", "key2": "val2", "key3": "val3"}
104 if some_var == "long strings"
105 else {"key": "val"}
106 )
107 ]
108 items = [
109 (
110 {"key1": "val1", "key2": "val2", "key3": "val3"}
111 if some_var == "long strings"
112 else {"key": "val"}
113 )
114 ] # comment
115
116 items = [
117 (
118 {"key1": "val1", "key2": "val2", "key3": "val3"} # comment
119 if some_var == "long strings"
120 else {"key": "val"}
121 )
122 ]
123
124 items = [ # comment
125 ( # comment
126 {"key1": "val1", "key2": "val2", "key3": "val3"}
127 if some_var == "long strings"
128 else {"key": "val"}
129 )
130 ]
131 items = [
132 (
133 {"key1": "val1", "key2": "val2", "key3": "val3"}
134 if some_var == "long strings"
135 else {"key": "val"}
136 ) # comment
137 ] # comment
138
139
140 # output
141 items = [(x for x in [1])]
142
143 items = [
144 {"key1": "val1", "key2": "val2", "key3": "val3"}
145 if some_var == "long strings"
146 else {"key": "val"}
147 ]
148 items = [{"key1": "val1", "key2": "val2"} if some_var == "" else {"key": "val"}]
149 items = [
150 "123456890123457890123468901234567890"
151 if some_var == "long strings"
152 else "123467890123467890"
153 ]
154 items = [
155 {"key1": "val1", "key2": "val2", "key3": "val3"}
156 and some_var == "long strings"
157 and {"key": "val"}
158 ]
159 items = [
160 "123456890123457890123468901234567890"
161 and some_var == "long strings"
162 and "123467890123467890"
163 ]
164 items = [
165 long_variable_name
166 and even_longer_variable_name
167 and yet_another_very_long_variable_name
168 ]
169
170 # Shouldn't remove trailing commas
171 items = [
172 (
173 {"key1": "val1", "key2": "val2", "key3": "val3"}
174 if some_var == "long strings"
175 else {"key": "val"}
176 ),
177 ]
178 items = [
179 (
180 {"key1": "val1", "key2": "val2", "key3": "val3"}
181 and some_var == "long strings"
182 and {"key": "val"}
183 ),
184 ]
185 items = [
186 (
187 "123456890123457890123468901234567890"
188 and some_var == "long strings"
189 and "123467890123467890"
190 ),
191 ]
192 items = [
193 (
194 long_variable_name
195 and even_longer_variable_name
196 and yet_another_very_long_variable_name
197 ),
198 ]
199
200 # Shouldn't add parentheses
201 items = [
202 {"key1": "val1", "key2": "val2", "key3": "val3"}
203 if some_var == "long strings"
204 else {"key": "val"}
205 ]
206 items = [{"key1": "val1", "key2": "val2"} if some_var == "" else {"key": "val"}]
207
208 # Shouldn't crash with comments
209 items = [ # comment
210 {"key1": "val1", "key2": "val2", "key3": "val3"}
211 if some_var == "long strings"
212 else {"key": "val"}
213 ]
214 items = [
215 {"key1": "val1", "key2": "val2", "key3": "val3"}
216 if some_var == "long strings"
217 else {"key": "val"}
218 ] # comment
219
220 items = [ # comment
221 {"key1": "val1", "key2": "val2", "key3": "val3"}
222 if some_var == "long strings"
223 else {"key": "val"}
224 ]
225 items = [
226 {"key1": "val1", "key2": "val2", "key3": "val3"}
227 if some_var == "long strings"
228 else {"key": "val"}
229 ] # comment
230
231 items = [
232 {"key1": "val1", "key2": "val2", "key3": "val3"} # comment
233 if some_var == "long strings"
234 else {"key": "val"}
235 ]
236
237 items = [ # comment # comment
238 {"key1": "val1", "key2": "val2", "key3": "val3"}
239 if some_var == "long strings"
240 else {"key": "val"}
241 ]
242 items = [
243 {"key1": "val1", "key2": "val2", "key3": "val3"}
244 if some_var == "long strings"
245 else {"key": "val"}
246 ] # comment # comment