]> git.madduck.net Git - etc/vim.git/blob - tests/data/preview/comments9.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 some typos (#3474)
[etc/vim.git] / tests / data / preview / comments9.py
1 # Test for https://github.com/psf/black/issues/246.
2
3 some = statement
4 # This comment should be split from the statement above by two lines.
5 def function():
6     pass
7
8
9 some = statement
10 # This multiline comments section
11 # should be split from the statement
12 # above by two lines.
13 def function():
14     pass
15
16
17 some = statement
18 # This comment should be split from the statement above by two lines.
19 async def async_function():
20     pass
21
22
23 some = statement
24 # This comment should be split from the statement above by two lines.
25 class MyClass:
26     pass
27
28
29 some = statement
30 # This should be stick to the statement above
31
32 # This should be split from the above by two lines
33 class MyClassWithComplexLeadingComments:
34     pass
35
36
37 class ClassWithDocstring:
38     """A docstring."""
39 # Leading comment after a class with just a docstring
40 class MyClassAfterAnotherClassWithDocstring:
41     pass
42
43
44 some = statement
45 # leading 1
46 @deco1
47 # leading 2
48 # leading 2 extra
49 @deco2(with_args=True)
50 # leading 3
51 @deco3
52 # leading 4
53 def decorated():
54     pass
55
56
57 some = statement
58 # leading 1
59 @deco1
60 # leading 2
61 @deco2(with_args=True)
62
63 # leading 3 that already has an empty line
64 @deco3
65 # leading 4
66 def decorated_with_split_leading_comments():
67     pass
68
69
70 some = statement
71 # leading 1
72 @deco1
73 # leading 2
74 @deco2(with_args=True)
75 # leading 3
76 @deco3
77
78 # leading 4 that already has an empty line
79 def decorated_with_split_leading_comments():
80     pass
81
82
83 def main():
84     if a:
85         # Leading comment before inline function
86         def inline():
87             pass
88         # Another leading comment
89         def another_inline():
90             pass
91     else:
92         # More leading comments
93         def inline_after_else():
94             pass
95
96
97 if a:
98     # Leading comment before "top-level inline" function
99     def top_level_quote_inline():
100         pass
101     # Another leading comment
102     def another_top_level_quote_inline_inline():
103         pass
104 else:
105     # More leading comments
106     def top_level_quote_inline_after_else():
107         pass
108
109
110 class MyClass:
111     # First method has no empty lines between bare class def.
112     # More comments.
113     def first_method(self):
114         pass
115
116
117 # Regression test for https://github.com/psf/black/issues/3454.
118 def foo():
119     pass
120     # Trailing comment that belongs to this function
121
122
123 @decorator1
124 @decorator2  # fmt: skip
125 def bar():
126     pass
127
128
129 # Regression test for https://github.com/psf/black/issues/3454.
130 def foo():
131     pass
132     # Trailing comment that belongs to this function.
133     # NOTE this comment only has one empty line below, and the formatter
134     # should enforce two blank lines.
135
136 @decorator1
137 # A standalone comment
138 def bar():
139     pass
140
141
142 # output
143
144
145 # Test for https://github.com/psf/black/issues/246.
146
147 some = statement
148
149
150 # This comment should be split from the statement above by two lines.
151 def function():
152     pass
153
154
155 some = statement
156
157
158 # This multiline comments section
159 # should be split from the statement
160 # above by two lines.
161 def function():
162     pass
163
164
165 some = statement
166
167
168 # This comment should be split from the statement above by two lines.
169 async def async_function():
170     pass
171
172
173 some = statement
174
175
176 # This comment should be split from the statement above by two lines.
177 class MyClass:
178     pass
179
180
181 some = statement
182 # This should be stick to the statement above
183
184
185 # This should be split from the above by two lines
186 class MyClassWithComplexLeadingComments:
187     pass
188
189
190 class ClassWithDocstring:
191     """A docstring."""
192
193
194 # Leading comment after a class with just a docstring
195 class MyClassAfterAnotherClassWithDocstring:
196     pass
197
198
199 some = statement
200
201
202 # leading 1
203 @deco1
204 # leading 2
205 # leading 2 extra
206 @deco2(with_args=True)
207 # leading 3
208 @deco3
209 # leading 4
210 def decorated():
211     pass
212
213
214 some = statement
215
216
217 # leading 1
218 @deco1
219 # leading 2
220 @deco2(with_args=True)
221
222 # leading 3 that already has an empty line
223 @deco3
224 # leading 4
225 def decorated_with_split_leading_comments():
226     pass
227
228
229 some = statement
230
231
232 # leading 1
233 @deco1
234 # leading 2
235 @deco2(with_args=True)
236 # leading 3
237 @deco3
238
239 # leading 4 that already has an empty line
240 def decorated_with_split_leading_comments():
241     pass
242
243
244 def main():
245     if a:
246         # Leading comment before inline function
247         def inline():
248             pass
249
250         # Another leading comment
251         def another_inline():
252             pass
253
254     else:
255         # More leading comments
256         def inline_after_else():
257             pass
258
259
260 if a:
261     # Leading comment before "top-level inline" function
262     def top_level_quote_inline():
263         pass
264
265     # Another leading comment
266     def another_top_level_quote_inline_inline():
267         pass
268
269 else:
270     # More leading comments
271     def top_level_quote_inline_after_else():
272         pass
273
274
275 class MyClass:
276     # First method has no empty lines between bare class def.
277     # More comments.
278     def first_method(self):
279         pass
280
281
282 # Regression test for https://github.com/psf/black/issues/3454.
283 def foo():
284     pass
285     # Trailing comment that belongs to this function
286
287
288 @decorator1
289 @decorator2  # fmt: skip
290 def bar():
291     pass
292
293
294 # Regression test for https://github.com/psf/black/issues/3454.
295 def foo():
296     pass
297     # Trailing comment that belongs to this function.
298     # NOTE this comment only has one empty line below, and the formatter
299     # should enforce two blank lines.
300
301
302 @decorator1
303 # A standalone comment
304 def bar():
305     pass