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

Extract formatting tests (#1785)
[etc/vim.git] / tests / data / 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 ### SECTION COMMENT ###
159 #######################
160
161
162 instruction()
163
164 # END COMMENTS
165 # MORE END COMMENTS
166
167
168 # output
169
170
171 from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
172     MyLovelyCompanyTeamProjectComponent,  # NOT DRY
173 )
174 from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
175     MyLovelyCompanyTeamProjectComponent as component,  # DRY
176 )
177
178 # Please keep __all__ alphabetized within each category.
179
180 __all__ = [
181     # Super-special typing primitives.
182     "Any",
183     "Callable",
184     "ClassVar",
185     # ABCs (from collections.abc).
186     "AbstractSet",  # collections.abc.Set.
187     "ByteString",
188     "Container",
189     # Concrete collection types.
190     "Counter",
191     "Deque",
192     "Dict",
193     "DefaultDict",
194     "List",
195     "Set",
196     "FrozenSet",
197     "NamedTuple",  # Not really a type.
198     "Generator",
199 ]
200
201 not_shareables = [
202     # singletons
203     True,
204     False,
205     NotImplemented,
206     ...,
207     # builtin types and objects
208     type,
209     object,
210     object(),
211     Exception(),
212     42,
213     100.0,
214     "spam",
215     # user-defined types and objects
216     Cheese,
217     Cheese("Wensleydale"),
218     SubBytes(b"spam"),
219 ]
220
221 if "PYTHON" in os.environ:
222     add_compiler(compiler_from_env())
223 else:
224     # for compiler in compilers.values():
225     # add_compiler(compiler)
226     add_compiler(compilers[(7.0, 32)])
227     # add_compiler(compilers[(7.1, 64)])
228
229 # Comment before function.
230 def inline_comments_in_brackets_ruin_everything():
231     if typedargslist:
232         parameters.children = [children[0], body, children[-1]]  # (1  # )1
233         parameters.children = [
234             children[0],
235             body,
236             children[-1],  # type: ignore
237         ]
238     else:
239         parameters.children = [
240             parameters.children[0],  # (2 what if this was actually long
241             body,
242             parameters.children[-1],  # )2
243         ]
244         parameters.children = [parameters.what_if_this_was_actually_long.children[0], body, parameters.children[-1]]  # type: ignore
245     if (
246         self._proc is not None
247         # has the child process finished?
248         and self._returncode is None
249         # the child process has finished, but the
250         # transport hasn't been notified yet?
251         and self._proc.poll() is None
252     ):
253         pass
254     # no newline before or after
255     short = [
256         # one
257         1,
258         # two
259         2,
260     ]
261
262     # no newline after
263     call(
264         arg1,
265         arg2,
266         """
267 short
268 """,
269         arg3=True,
270     )
271
272     ############################################################################
273
274     call2(
275         # short
276         arg1,
277         # but
278         arg2,
279         # multiline
280         """
281 short
282 """,
283         # yup
284         arg3=True,
285     )
286     lcomp = [
287         element for element in collection if element is not None  # yup  # yup  # right
288     ]
289     lcomp2 = [
290         # hello
291         element
292         # yup
293         for element in collection
294         # right
295         if element is not None
296     ]
297     lcomp3 = [
298         # This one is actually too long to fit in a single line.
299         element.split("\n", 1)[0]
300         # yup
301         for element in collection.select_elements()
302         # right
303         if element is not None
304     ]
305     while True:
306         if False:
307             continue
308
309             # and round and round we go
310         # and round and round we go
311
312     # let's return
313     return Node(
314         syms.simple_stmt,
315         [Node(statement, result), Leaf(token.NEWLINE, "\n")],  # FIXME: \r\n?
316     )
317
318
319 CONFIG_FILES = (
320     [
321         CONFIG_FILE,
322     ]
323     + SHARED_CONFIG_FILES
324     + USER_CONFIG_FILES
325 )  # type: Final
326
327
328 class Test:
329     def _init_host(self, parsed) -> None:
330         if parsed.hostname is None or not parsed.hostname.strip():  # type: ignore
331             pass
332
333
334 #######################
335 ### SECTION COMMENT ###
336 #######################
337
338
339 instruction()
340
341 # END COMMENTS
342 # MORE END COMMENTS