]> git.madduck.net Git - etc/vim.git/blob - tests/data/simple_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 new mypy error in blib2to3 (#3674)
[etc/vim.git] / tests / data / simple_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 ### SECTION COMMENT ###
159 #######################
160
161
162 instruction()#comment with bad spacing
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
230 # Comment before function.
231 def inline_comments_in_brackets_ruin_everything():
232     if typedargslist:
233         parameters.children = [children[0], body, children[-1]]  # (1  # )1
234         parameters.children = [
235             children[0],
236             body,
237             children[-1],  # type: ignore
238         ]
239     else:
240         parameters.children = [
241             parameters.children[0],  # (2 what if this was actually long
242             body,
243             parameters.children[-1],  # )2
244         ]
245         parameters.children = [parameters.what_if_this_was_actually_long.children[0], body, parameters.children[-1]]  # type: ignore
246     if (
247         self._proc is not None
248         # has the child process finished?
249         and self._returncode is None
250         # the child process has finished, but the
251         # transport hasn't been notified yet?
252         and self._proc.poll() is None
253     ):
254         pass
255     # no newline before or after
256     short = [
257         # one
258         1,
259         # two
260         2,
261     ]
262
263     # no newline after
264     call(
265         arg1,
266         arg2,
267         """
268 short
269 """,
270         arg3=True,
271     )
272
273     ############################################################################
274
275     call2(
276         # short
277         arg1,
278         # but
279         arg2,
280         # multiline
281         """
282 short
283 """,
284         # yup
285         arg3=True,
286     )
287     lcomp = [
288         element for element in collection if element is not None  # yup  # yup  # right
289     ]
290     lcomp2 = [
291         # hello
292         element
293         # yup
294         for element in collection
295         # right
296         if element is not None
297     ]
298     lcomp3 = [
299         # This one is actually too long to fit in a single line.
300         element.split("\n", 1)[0]
301         # yup
302         for element in collection.select_elements()
303         # right
304         if element is not None
305     ]
306     while True:
307         if False:
308             continue
309
310             # and round and round we go
311         # and round and round we go
312
313     # let's return
314     return Node(
315         syms.simple_stmt,
316         [Node(statement, result), Leaf(token.NEWLINE, "\n")],  # FIXME: \r\n?
317     )
318
319
320 CONFIG_FILES = (
321     [
322         CONFIG_FILE,
323     ]
324     + SHARED_CONFIG_FILES
325     + USER_CONFIG_FILES
326 )  # type: Final
327
328
329 class Test:
330     def _init_host(self, parsed) -> None:
331         if parsed.hostname is None or not parsed.hostname.strip():  # type: ignore
332             pass
333
334
335 #######################
336 ### SECTION COMMENT ###
337 #######################
338
339
340 instruction()  # comment with bad spacing
341
342 # END COMMENTS
343 # MORE END COMMENTS