]> git.madduck.net Git - etc/vim.git/blob - tests/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:

Make sure --verbose trumps --quiet
[etc/vim.git] / tests / comments2.py
1 # Please keep __all__ alphabetized within each category.
2
3 __all__ = [
4     # Super-special typing primitives.
5     'Any',
6     'Callable',
7     'ClassVar',
8
9     # ABCs (from collections.abc).
10     'AbstractSet',  # collections.abc.Set.
11     'ByteString',
12     'Container',
13
14     # Concrete collection types.
15     'Counter',
16     'Deque',
17     'Dict',
18     'DefaultDict',
19     'List',
20     'Set',
21     'FrozenSet',
22     'NamedTuple',  # Not really a type.
23     'Generator',
24 ]
25
26 not_shareables = [
27     # singletons
28     True,
29     False,
30     NotImplemented, ...,
31     # builtin types and objects
32     type,
33     object,
34     object(),
35     Exception(),
36     42,
37     100.0,
38     "spam",
39     # user-defined types and objects
40     Cheese,
41     Cheese("Wensleydale"),
42     SubBytes(b"spam"),
43 ]
44
45 if 'PYTHON' in os.environ:
46     add_compiler(compiler_from_env())
47 else:
48     # for compiler in compilers.values():
49          # add_compiler(compiler)
50     add_compiler(compilers[(7.0, 32)])
51     # add_compiler(compilers[(7.1, 64)])
52
53 # Comment before function.
54 def inline_comments_in_brackets_ruin_everything():
55     if typedargslist:
56         parameters.children = [
57             children[0],  # (1
58             body,
59             children[-1],  # )1
60         ]
61     else:
62         parameters.children = [
63             parameters.children[0],  # (2 what if this was actually long
64             body,
65             parameters.children[-1],  # )2
66         ]
67     if (self._proc is not None
68             # has the child process finished?
69             and self._returncode is None
70             # the child process has finished, but the
71             # transport hasn't been notified yet?
72             and self._proc.poll() is None):
73         pass
74     # no newline before or after
75     short = [
76      # one
77      1,
78      # two
79      2]
80
81     # no newline after
82     call(arg1, arg2, """
83 short
84 """, arg3=True)
85
86     ############################################################################
87
88     call2(
89     #short
90     arg1,
91     #but
92     arg2,
93     #multiline
94     """
95 short
96 """,
97     # yup
98     arg3=True)
99     lcomp = [
100         element  # yup
101         for element in collection  # yup
102         if element is not None  # right
103     ]
104     lcomp2 = [
105         # hello
106         element
107         # yup
108         for element in collection
109         # right
110         if element is not None
111     ]
112     lcomp3 = [
113         # This one is actually too long to fit in a single line.
114         element.split('\n', 1)[0]
115         # yup
116         for element in collection.select_elements()
117         # right
118         if element is not None
119     ]
120     while True:
121         if False:
122             continue
123
124             # and round and round we go
125         # and round and round we go
126
127    # let's return
128     return Node(
129         syms.simple_stmt,
130         [
131             Node(statement, result),
132             Leaf(token.NEWLINE, '\n'),  # FIXME: \r\n?
133         ],
134     )
135
136
137 #######################
138 ### SECTION COMMENT ###
139 #######################
140
141
142 instruction()
143
144 # END COMMENTS
145 # MORE END COMMENTS
146
147
148 # output
149
150
151 # Please keep __all__ alphabetized within each category.
152
153 __all__ = [
154     # Super-special typing primitives.
155     "Any",
156     "Callable",
157     "ClassVar",
158     # ABCs (from collections.abc).
159     "AbstractSet",  # collections.abc.Set.
160     "ByteString",
161     "Container",
162     # Concrete collection types.
163     "Counter",
164     "Deque",
165     "Dict",
166     "DefaultDict",
167     "List",
168     "Set",
169     "FrozenSet",
170     "NamedTuple",  # Not really a type.
171     "Generator",
172 ]
173
174 not_shareables = [
175     # singletons
176     True,
177     False,
178     NotImplemented,
179     ...,
180     # builtin types and objects
181     type,
182     object,
183     object(),
184     Exception(),
185     42,
186     100.0,
187     "spam",
188     # user-defined types and objects
189     Cheese,
190     Cheese("Wensleydale"),
191     SubBytes(b"spam"),
192 ]
193
194 if "PYTHON" in os.environ:
195     add_compiler(compiler_from_env())
196 else:
197     # for compiler in compilers.values():
198     # add_compiler(compiler)
199     add_compiler(compilers[(7.0, 32)])
200     # add_compiler(compilers[(7.1, 64)])
201
202 # Comment before function.
203 def inline_comments_in_brackets_ruin_everything():
204     if typedargslist:
205         parameters.children = [children[0], body, children[-1]]  # (1  # )1
206     else:
207         parameters.children = [
208             parameters.children[0],  # (2 what if this was actually long
209             body,
210             parameters.children[-1],  # )2
211         ]
212     if (
213         self._proc is not None
214         # has the child process finished?
215         and self._returncode is None
216         # the child process has finished, but the
217         # transport hasn't been notified yet?
218         and self._proc.poll() is None
219     ):
220         pass
221     # no newline before or after
222     short = [
223         # one
224         1,
225         # two
226         2,
227     ]
228
229     # no newline after
230     call(
231         arg1,
232         arg2,
233         """
234 short
235 """,
236         arg3=True,
237     )
238
239     ############################################################################
240
241     call2(
242         # short
243         arg1,
244         # but
245         arg2,
246         # multiline
247         """
248 short
249 """,
250         # yup
251         arg3=True,
252     )
253     lcomp = [
254         element for element in collection if element is not None  # yup  # yup  # right
255     ]
256     lcomp2 = [
257         # hello
258         element
259         # yup
260         for element in collection
261         # right
262         if element is not None
263     ]
264     lcomp3 = [
265         # This one is actually too long to fit in a single line.
266         element.split("\n", 1)[0]
267         # yup
268         for element in collection.select_elements()
269         # right
270         if element is not None
271     ]
272     while True:
273         if False:
274             continue
275
276             # and round and round we go
277         # and round and round we go
278
279     # let's return
280     return Node(
281         syms.simple_stmt,
282         [Node(statement, result), Leaf(token.NEWLINE, "\n")],  # FIXME: \r\n?
283     )
284
285
286 #######################
287 ### SECTION COMMENT ###
288 #######################
289
290
291 instruction()
292
293 # END COMMENTS
294 # MORE END COMMENTS