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

Improve an error message when failed to load pyproject.toml (#653)
[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     else:
69         parameters.children = [
70             parameters.children[0],  # (2 what if this was actually long
71             body,
72             parameters.children[-1],  # )2
73         ]
74     if (self._proc is not None
75             # has the child process finished?
76             and self._returncode is None
77             # the child process has finished, but the
78             # transport hasn't been notified yet?
79             and self._proc.poll() is None):
80         pass
81     # no newline before or after
82     short = [
83      # one
84      1,
85      # two
86      2]
87
88     # no newline after
89     call(arg1, arg2, """
90 short
91 """, arg3=True)
92
93     ############################################################################
94
95     call2(
96     #short
97     arg1,
98     #but
99     arg2,
100     #multiline
101     """
102 short
103 """,
104     # yup
105     arg3=True)
106     lcomp = [
107         element  # yup
108         for element in collection  # yup
109         if element is not None  # right
110     ]
111     lcomp2 = [
112         # hello
113         element
114         # yup
115         for element in collection
116         # right
117         if element is not None
118     ]
119     lcomp3 = [
120         # This one is actually too long to fit in a single line.
121         element.split('\n', 1)[0]
122         # yup
123         for element in collection.select_elements()
124         # right
125         if element is not None
126     ]
127     while True:
128         if False:
129             continue
130
131             # and round and round we go
132         # and round and round we go
133
134    # let's return
135     return Node(
136         syms.simple_stmt,
137         [
138             Node(statement, result),
139             Leaf(token.NEWLINE, '\n'),  # FIXME: \r\n?
140         ],
141     )
142
143
144 #######################
145 ### SECTION COMMENT ###
146 #######################
147
148
149 instruction()
150
151 # END COMMENTS
152 # MORE END COMMENTS
153
154
155 # output
156
157
158 from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
159     MyLovelyCompanyTeamProjectComponent,  # NOT DRY
160 )
161 from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
162     MyLovelyCompanyTeamProjectComponent as component,  # DRY
163 )
164
165 # Please keep __all__ alphabetized within each category.
166
167 __all__ = [
168     # Super-special typing primitives.
169     "Any",
170     "Callable",
171     "ClassVar",
172     # ABCs (from collections.abc).
173     "AbstractSet",  # collections.abc.Set.
174     "ByteString",
175     "Container",
176     # Concrete collection types.
177     "Counter",
178     "Deque",
179     "Dict",
180     "DefaultDict",
181     "List",
182     "Set",
183     "FrozenSet",
184     "NamedTuple",  # Not really a type.
185     "Generator",
186 ]
187
188 not_shareables = [
189     # singletons
190     True,
191     False,
192     NotImplemented,
193     ...,
194     # builtin types and objects
195     type,
196     object,
197     object(),
198     Exception(),
199     42,
200     100.0,
201     "spam",
202     # user-defined types and objects
203     Cheese,
204     Cheese("Wensleydale"),
205     SubBytes(b"spam"),
206 ]
207
208 if "PYTHON" in os.environ:
209     add_compiler(compiler_from_env())
210 else:
211     # for compiler in compilers.values():
212     # add_compiler(compiler)
213     add_compiler(compilers[(7.0, 32)])
214     # add_compiler(compilers[(7.1, 64)])
215
216 # Comment before function.
217 def inline_comments_in_brackets_ruin_everything():
218     if typedargslist:
219         parameters.children = [children[0], body, children[-1]]  # (1  # )1
220     else:
221         parameters.children = [
222             parameters.children[0],  # (2 what if this was actually long
223             body,
224             parameters.children[-1],  # )2
225         ]
226     if (
227         self._proc is not None
228         # has the child process finished?
229         and self._returncode is None
230         # the child process has finished, but the
231         # transport hasn't been notified yet?
232         and self._proc.poll() is None
233     ):
234         pass
235     # no newline before or after
236     short = [
237         # one
238         1,
239         # two
240         2,
241     ]
242
243     # no newline after
244     call(
245         arg1,
246         arg2,
247         """
248 short
249 """,
250         arg3=True,
251     )
252
253     ############################################################################
254
255     call2(
256         # short
257         arg1,
258         # but
259         arg2,
260         # multiline
261         """
262 short
263 """,
264         # yup
265         arg3=True,
266     )
267     lcomp = [
268         element for element in collection if element is not None  # yup  # yup  # right
269     ]
270     lcomp2 = [
271         # hello
272         element
273         # yup
274         for element in collection
275         # right
276         if element is not None
277     ]
278     lcomp3 = [
279         # This one is actually too long to fit in a single line.
280         element.split("\n", 1)[0]
281         # yup
282         for element in collection.select_elements()
283         # right
284         if element is not None
285     ]
286     while True:
287         if False:
288             continue
289
290             # and round and round we go
291         # and round and round we go
292
293     # let's return
294     return Node(
295         syms.simple_stmt,
296         [Node(statement, result), Leaf(token.NEWLINE, "\n")],  # FIXME: \r\n?
297     )
298
299
300 #######################
301 ### SECTION COMMENT ###
302 #######################
303
304
305 instruction()
306
307 # END COMMENTS
308 # MORE END COMMENTS