]> git.madduck.net Git - etc/vim.git/blob - tests/data/preview_py_310/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:

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