]> 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:

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