]> git.madduck.net Git - etc/vim.git/blob - tests/data/cases/comments2.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 long lines with power operator(s) getting splitted before line length (#3942)
[etc/vim.git] / tests / data / cases / comments2.py
1 from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
2     MyLovelyCompanyTeamProjectComponent  # NOT DRY
3 )
4 from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
5     MyLovelyCompanyTeamProjectComponent as component  # DRY
6 )
7
8 # Please keep __all__ alphabetized within each category.
9
10 __all__ = [
11     # Super-special typing primitives.
12     'Any',
13     'Callable',
14     'ClassVar',
15
16     # ABCs (from collections.abc).
17     'AbstractSet',  # collections.abc.Set.
18     'ByteString',
19     'Container',
20
21     # Concrete collection types.
22     'Counter',
23     'Deque',
24     'Dict',
25     'DefaultDict',
26     'List',
27     'Set',
28     'FrozenSet',
29     'NamedTuple',  # Not really a type.
30     'Generator',
31 ]
32
33 not_shareables = [
34     # singletons
35     True,
36     False,
37     NotImplemented, ...,
38     # builtin types and objects
39     type,
40     object,
41     object(),
42     Exception(),
43     42,
44     100.0,
45     "spam",
46     # user-defined types and objects
47     Cheese,
48     Cheese("Wensleydale"),
49     SubBytes(b"spam"),
50 ]
51
52 if 'PYTHON' in os.environ:
53     add_compiler(compiler_from_env())
54 else:
55     # for compiler in compilers.values():
56          # add_compiler(compiler)
57     add_compiler(compilers[(7.0, 32)])
58     # add_compiler(compilers[(7.1, 64)])
59
60 # Comment before function.
61 def inline_comments_in_brackets_ruin_everything():
62     if typedargslist:
63         parameters.children = [
64             children[0],  # (1
65             body,
66             children[-1]  # )1
67         ]
68         parameters.children = [
69             children[0],
70             body,
71             children[-1],  # type: ignore
72         ]
73     else:
74         parameters.children = [
75             parameters.children[0],  # (2 what if this was actually long
76             body,
77             parameters.children[-1],  # )2
78         ]
79         parameters.children = [parameters.what_if_this_was_actually_long.children[0], body, parameters.children[-1]]  # type: ignore
80     if (self._proc is not None
81             # has the child process finished?
82             and self._returncode is None
83             # the child process has finished, but the
84             # transport hasn't been notified yet?
85             and self._proc.poll() is None):
86         pass
87     # no newline before or after
88     short = [
89      # one
90      1,
91      # two
92      2]
93
94     # no newline after
95     call(arg1, arg2, """
96 short
97 """, arg3=True)
98
99     ############################################################################
100
101     call2(
102     #short
103     arg1,
104     #but
105     arg2,
106     #multiline
107     """
108 short
109 """,
110     # yup
111     arg3=True)
112     lcomp = [
113         element  # yup
114         for element in collection  # yup
115         if element is not None  # right
116     ]
117     lcomp2 = [
118         # hello
119         element
120         # yup
121         for element in collection
122         # right
123         if element is not None
124     ]
125     lcomp3 = [
126         # This one is actually too long to fit in a single line.
127         element.split('\n', 1)[0]
128         # yup
129         for element in collection.select_elements()
130         # right
131         if element is not None
132     ]
133     while True:
134         if False:
135             continue
136
137             # and round and round we go
138         # and round and round we go
139
140    # let's return
141     return Node(
142         syms.simple_stmt,
143         [
144             Node(statement, result),
145             Leaf(token.NEWLINE, '\n')  # FIXME: \r\n?
146         ],
147     )
148
149 CONFIG_FILES = [CONFIG_FILE, ] + SHARED_CONFIG_FILES + USER_CONFIG_FILES  # type: Final
150
151 class Test:
152     def _init_host(self, parsed) -> None:
153         if (parsed.hostname is None or  # type: ignore
154                 not parsed.hostname.strip()):
155             pass
156
157
158 a = "type comment with trailing space"  # type: str   
159
160 #######################
161 ### SECTION COMMENT ###
162 #######################
163
164
165 instruction()#comment with bad spacing
166
167 # END COMMENTS
168 # MORE END COMMENTS
169
170
171 # output
172
173
174 from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
175     MyLovelyCompanyTeamProjectComponent,  # NOT DRY
176 )
177 from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
178     MyLovelyCompanyTeamProjectComponent as component,  # DRY
179 )
180
181 # Please keep __all__ alphabetized within each category.
182
183 __all__ = [
184     # Super-special typing primitives.
185     "Any",
186     "Callable",
187     "ClassVar",
188     # ABCs (from collections.abc).
189     "AbstractSet",  # collections.abc.Set.
190     "ByteString",
191     "Container",
192     # Concrete collection types.
193     "Counter",
194     "Deque",
195     "Dict",
196     "DefaultDict",
197     "List",
198     "Set",
199     "FrozenSet",
200     "NamedTuple",  # Not really a type.
201     "Generator",
202 ]
203
204 not_shareables = [
205     # singletons
206     True,
207     False,
208     NotImplemented,
209     ...,
210     # builtin types and objects
211     type,
212     object,
213     object(),
214     Exception(),
215     42,
216     100.0,
217     "spam",
218     # user-defined types and objects
219     Cheese,
220     Cheese("Wensleydale"),
221     SubBytes(b"spam"),
222 ]
223
224 if "PYTHON" in os.environ:
225     add_compiler(compiler_from_env())
226 else:
227     # for compiler in compilers.values():
228     # add_compiler(compiler)
229     add_compiler(compilers[(7.0, 32)])
230     # add_compiler(compilers[(7.1, 64)])
231
232
233 # Comment before function.
234 def inline_comments_in_brackets_ruin_everything():
235     if typedargslist:
236         parameters.children = [children[0], body, children[-1]]  # (1  # )1
237         parameters.children = [
238             children[0],
239             body,
240             children[-1],  # type: ignore
241         ]
242     else:
243         parameters.children = [
244             parameters.children[0],  # (2 what if this was actually long
245             body,
246             parameters.children[-1],  # )2
247         ]
248         parameters.children = [parameters.what_if_this_was_actually_long.children[0], body, parameters.children[-1]]  # type: ignore
249     if (
250         self._proc is not None
251         # has the child process finished?
252         and self._returncode is None
253         # the child process has finished, but the
254         # transport hasn't been notified yet?
255         and self._proc.poll() is None
256     ):
257         pass
258     # no newline before or after
259     short = [
260         # one
261         1,
262         # two
263         2,
264     ]
265
266     # no newline after
267     call(
268         arg1,
269         arg2,
270         """
271 short
272 """,
273         arg3=True,
274     )
275
276     ############################################################################
277
278     call2(
279         # short
280         arg1,
281         # but
282         arg2,
283         # multiline
284         """
285 short
286 """,
287         # yup
288         arg3=True,
289     )
290     lcomp = [
291         element for element in collection if element is not None  # yup  # yup  # right
292     ]
293     lcomp2 = [
294         # hello
295         element
296         # yup
297         for element in collection
298         # right
299         if element is not None
300     ]
301     lcomp3 = [
302         # This one is actually too long to fit in a single line.
303         element.split("\n", 1)[0]
304         # yup
305         for element in collection.select_elements()
306         # right
307         if element is not None
308     ]
309     while True:
310         if False:
311             continue
312
313             # and round and round we go
314         # and round and round we go
315
316     # let's return
317     return Node(
318         syms.simple_stmt,
319         [Node(statement, result), Leaf(token.NEWLINE, "\n")],  # FIXME: \r\n?
320     )
321
322
323 CONFIG_FILES = (
324     [
325         CONFIG_FILE,
326     ]
327     + SHARED_CONFIG_FILES
328     + USER_CONFIG_FILES
329 )  # type: Final
330
331
332 class Test:
333     def _init_host(self, parsed) -> None:
334         if parsed.hostname is None or not parsed.hostname.strip():  # type: ignore
335             pass
336
337
338 a = "type comment with trailing space"  # type: str
339
340 #######################
341 ### SECTION COMMENT ###
342 #######################
343
344
345 instruction()  # comment with bad spacing
346
347 # END COMMENTS
348 # MORE END COMMENTS