]> 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 duplicate paragraph about blackd headers (#1124)
[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 = [parameters.what_if_this_was_actually_long.children[0], body, parameters.children[-1]]  # type: ignore
239     if (
240         self._proc is not None
241         # has the child process finished?
242         and self._returncode is None
243         # the child process has finished, but the
244         # transport hasn't been notified yet?
245         and self._proc.poll() is None
246     ):
247         pass
248     # no newline before or after
249     short = [
250         # one
251         1,
252         # two
253         2,
254     ]
255
256     # no newline after
257     call(
258         arg1,
259         arg2,
260         """
261 short
262 """,
263         arg3=True,
264     )
265
266     ############################################################################
267
268     call2(
269         # short
270         arg1,
271         # but
272         arg2,
273         # multiline
274         """
275 short
276 """,
277         # yup
278         arg3=True,
279     )
280     lcomp = [
281         element for element in collection if element is not None  # yup  # yup  # right
282     ]
283     lcomp2 = [
284         # hello
285         element
286         # yup
287         for element in collection
288         # right
289         if element is not None
290     ]
291     lcomp3 = [
292         # This one is actually too long to fit in a single line.
293         element.split("\n", 1)[0]
294         # yup
295         for element in collection.select_elements()
296         # right
297         if element is not None
298     ]
299     while True:
300         if False:
301             continue
302
303             # and round and round we go
304         # and round and round we go
305
306     # let's return
307     return Node(
308         syms.simple_stmt,
309         [Node(statement, result), Leaf(token.NEWLINE, "\n")],  # FIXME: \r\n?
310     )
311
312
313 CONFIG_FILES = [CONFIG_FILE,] + SHARED_CONFIG_FILES + USER_CONFIG_FILES  # type: Final
314
315 #######################
316 ### SECTION COMMENT ###
317 #######################
318
319
320 instruction()
321
322 # END COMMENTS
323 # MORE END COMMENTS