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

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