]> git.madduck.net Git - etc/vim.git/blob - tests/data/cases/funcdef_return_type_trailing_comma.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Fix merging implicit multiline strings that have inline comments (#3956)
[etc/vim.git] / tests / data / cases / funcdef_return_type_trailing_comma.py
1 # flags: --preview --minimum-version=3.10
2 # normal, short, function definition
3 def foo(a, b) -> tuple[int, float]: ...
4
5
6 # normal, short, function definition w/o return type
7 def foo(a, b): ...
8
9
10 # no splitting
11 def foo(a: A, b: B) -> list[p, q]:
12     pass
13
14
15 # magic trailing comma in param list
16 def foo(a, b,): ...
17
18
19 # magic trailing comma in nested params in param list
20 def foo(a, b: tuple[int, float,]): ...
21
22
23 # magic trailing comma in return type, no params
24 def a() -> tuple[
25     a,
26     b,
27 ]: ...
28
29
30 # magic trailing comma in return type, params
31 def foo(a: A, b: B) -> list[
32     p,
33     q,
34 ]:
35     pass
36
37
38 # magic trailing comma in param list and in return type
39 def foo(
40     a: a,
41     b: b,
42 ) -> list[
43     a,
44     a,
45 ]:
46     pass
47
48
49 # long function definition, param list is longer
50 def aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
51     bbbbbbbbbbbbbbbbbb,
52 ) -> cccccccccccccccccccccccccccccc: ...
53
54
55 # long function definition, return type is longer
56 # this should maybe split on rhs?
57 def aaaaaaaaaaaaaaaaa(bbbbbbbbbbbbbbbbbb) -> list[
58     Ccccccccccccccccccccccccccccccccccccccccccccccccccc, Dddddd
59 ]: ...
60
61
62 # long return type, no param list
63 def foo() -> list[
64     Loooooooooooooooooooooooooooooooooooong,
65     Loooooooooooooooooooong,
66     Looooooooooooong,
67 ]: ...
68
69
70 # long function name, no param list, no return value
71 def thiiiiiiiiiiiiiiiiiis_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiis_veeeeeeeeeeeeeeeeeeeeeeery_looooooong():
72     pass
73
74
75 # long function name, no param list
76 def thiiiiiiiiiiiiiiiiiis_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiis_veeeeeeeeeeeeeeeeeeeeeeery_looooooong() -> (
77     list[int, float]
78 ): ...
79
80
81 # long function name, no return value
82 def thiiiiiiiiiiiiiiiiiis_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiis_veeeeeeeeeeeeeeeeeeeeeeery_looooooong(
83     a, b
84 ): ...
85
86
87 # unskippable type hint (??)
88 def foo(a) -> list[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]:  # type: ignore
89     pass
90
91
92 def foo(a) -> list[
93     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
94 ]:  # abpedeifnore
95     pass
96
97 def foo(a, b: list[Bad],): ... # type: ignore
98
99 # don't lose any comments (no magic)
100 def foo( # 1
101     a, # 2
102     b) -> list[ # 3
103                a, # 4
104                b]: # 5
105         ... # 6
106
107
108 # don't lose any comments (param list magic)
109 def foo( # 1
110     a, # 2
111     b,) -> list[ # 3
112                a, # 4
113                b]: # 5
114         ... # 6
115
116
117 # don't lose any comments (return type magic)
118 def foo( # 1
119     a, # 2
120     b) -> list[ # 3
121                a, # 4
122                b,]: # 5
123         ... # 6
124
125
126 # don't lose any comments (both magic)
127 def foo( # 1
128     a, # 2
129     b,) -> list[ # 3
130                a, # 4
131                b,]: # 5
132         ... # 6
133
134 # real life example
135 def SimplePyFn(
136     context: hl.GeneratorContext,
137     buffer_input: Buffer[UInt8, 2],
138     func_input: Buffer[Int32, 2],
139     float_arg: Scalar[Float32],
140     offset: int = 0,
141 ) -> tuple[
142     Buffer[UInt8, 2],
143     Buffer[UInt8, 2],
144 ]: ...
145 # output
146 # normal, short, function definition
147 def foo(a, b) -> tuple[int, float]: ...
148
149
150 # normal, short, function definition w/o return type
151 def foo(a, b): ...
152
153
154 # no splitting
155 def foo(a: A, b: B) -> list[p, q]:
156     pass
157
158
159 # magic trailing comma in param list
160 def foo(
161     a,
162     b,
163 ): ...
164
165
166 # magic trailing comma in nested params in param list
167 def foo(
168     a,
169     b: tuple[
170         int,
171         float,
172     ],
173 ): ...
174
175
176 # magic trailing comma in return type, no params
177 def a() -> tuple[
178     a,
179     b,
180 ]: ...
181
182
183 # magic trailing comma in return type, params
184 def foo(a: A, b: B) -> list[
185     p,
186     q,
187 ]:
188     pass
189
190
191 # magic trailing comma in param list and in return type
192 def foo(
193     a: a,
194     b: b,
195 ) -> list[
196     a,
197     a,
198 ]:
199     pass
200
201
202 # long function definition, param list is longer
203 def aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
204     bbbbbbbbbbbbbbbbbb,
205 ) -> cccccccccccccccccccccccccccccc: ...
206
207
208 # long function definition, return type is longer
209 # this should maybe split on rhs?
210 def aaaaaaaaaaaaaaaaa(
211     bbbbbbbbbbbbbbbbbb,
212 ) -> list[Ccccccccccccccccccccccccccccccccccccccccccccccccccc, Dddddd]: ...
213
214
215 # long return type, no param list
216 def foo() -> list[
217     Loooooooooooooooooooooooooooooooooooong,
218     Loooooooooooooooooooong,
219     Looooooooooooong,
220 ]: ...
221
222
223 # long function name, no param list, no return value
224 def thiiiiiiiiiiiiiiiiiis_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiis_veeeeeeeeeeeeeeeeeeeeeeery_looooooong():
225     pass
226
227
228 # long function name, no param list
229 def thiiiiiiiiiiiiiiiiiis_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiis_veeeeeeeeeeeeeeeeeeeeeeery_looooooong() -> (
230     list[int, float]
231 ): ...
232
233
234 # long function name, no return value
235 def thiiiiiiiiiiiiiiiiiis_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiis_veeeeeeeeeeeeeeeeeeeeeeery_looooooong(
236     a, b
237 ): ...
238
239
240 # unskippable type hint (??)
241 def foo(a) -> list[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]:  # type: ignore
242     pass
243
244
245 def foo(
246     a,
247 ) -> list[
248     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
249 ]:  # abpedeifnore
250     pass
251
252
253 def foo(
254     a,
255     b: list[Bad],
256 ): ...  # type: ignore
257
258
259 # don't lose any comments (no magic)
260 def foo(a, b) -> list[a, b]:  # 1  # 2  # 3  # 4  # 5
261     ...  # 6
262
263
264 # don't lose any comments (param list magic)
265 def foo(  # 1
266     a,  # 2
267     b,
268 ) -> list[a, b]:  # 3  # 4  # 5
269     ...  # 6
270
271
272 # don't lose any comments (return type magic)
273 def foo(a, b) -> list[  # 1  # 2  # 3
274     a,  # 4
275     b,
276 ]:  # 5
277     ...  # 6
278
279
280 # don't lose any comments (both magic)
281 def foo(  # 1
282     a,  # 2
283     b,
284 ) -> list[  # 3
285     a,  # 4
286     b,
287 ]:  # 5
288     ...  # 6
289
290
291 # real life example
292 def SimplePyFn(
293     context: hl.GeneratorContext,
294     buffer_input: Buffer[UInt8, 2],
295     func_input: Buffer[Int32, 2],
296     float_arg: Scalar[Float32],
297     offset: int = 0,
298 ) -> tuple[
299     Buffer[UInt8, 2],
300     Buffer[UInt8, 2],
301 ]: ...