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

Fix placement of dictionary unpacking inside dict literals
[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 if 'PYTHON' in os.environ:
27     add_compiler(compiler_from_env())
28 else:
29     # for compiler in compilers.values():
30          # add_compiler(compiler)
31     add_compiler(compilers[(7.0, 32)])
32     # add_compiler(compilers[(7.1, 64)])
33
34 # Comment before function.
35 def inline_comments_in_brackets_ruin_everything():
36     if typedargslist:
37         parameters.children = [
38             parameters.children[0],  # (1
39             body,
40             parameters.children[-1],  # )1
41         ]
42     else:
43         parameters.children = [
44             parameters.children[0],  # (2 what if this was actually long
45             body,
46             parameters.children[-1],  # )2
47         ]
48     if (self._proc is not None
49             # has the child process finished?
50             and self._returncode is None
51             # the child process has finished, but the
52             # transport hasn't been notified yet?
53             and self._proc.poll() is None):
54         pass
55     # no newline before or after
56     short = [
57      # one
58      1,
59      # two
60      2]
61
62     # no newline after
63     call(arg1, arg2, """
64 short
65 """, arg3=True)
66
67     ############################################################################
68
69     call2(
70     #short
71     arg1,
72     #but
73     arg2,
74     #multiline
75     """
76 short
77 """,
78     # yup
79     arg3=True)
80     lcomp = [
81         element  # yup
82         for element in collection  # yup
83         if element is not None  # right
84     ]
85     lcomp2 = [
86         # hello
87         element
88         # yup
89         for element in collection
90         # right
91         if element is not None
92     ]
93     lcomp3 = [
94         # This one is actually too long to fit in a single line.
95         element.split('\n', 1)[0]
96         # yup
97         for element in collection.select_elements()
98         # right
99         if element is not None
100     ]
101     while True:
102         if False:
103             continue
104
105             # and round and round we go
106         # and round and round we go
107
108    # let's return
109     return Node(
110         syms.simple_stmt,
111         [
112             Node(statement, result),
113             Leaf(token.NEWLINE, '\n'),  # FIXME: \r\n?
114         ],
115     )
116
117
118 #######################
119 ### SECTION COMMENT ###
120 #######################
121
122
123 instruction()
124
125 # END COMMENTS
126 # MORE END COMMENTS
127
128
129 # output
130
131
132 # Please keep __all__ alphabetized within each category.
133
134 __all__ = [
135     # Super-special typing primitives.
136     "Any",
137     "Callable",
138     "ClassVar",
139     # ABCs (from collections.abc).
140     "AbstractSet",  # collections.abc.Set.
141     "ByteString",
142     "Container",
143     # Concrete collection types.
144     "Counter",
145     "Deque",
146     "Dict",
147     "DefaultDict",
148     "List",
149     "Set",
150     "FrozenSet",
151     "NamedTuple",  # Not really a type.
152     "Generator",
153 ]
154
155 if "PYTHON" in os.environ:
156     add_compiler(compiler_from_env())
157 else:
158     # for compiler in compilers.values():
159     # add_compiler(compiler)
160     add_compiler(compilers[(7.0, 32)])
161 # add_compiler(compilers[(7.1, 64)])
162
163 # Comment before function.
164
165
166 def inline_comments_in_brackets_ruin_everything():
167     if typedargslist:
168         parameters.children = [
169             parameters.children[0], body, parameters.children[-1]  # (1  # )1
170         ]
171     else:
172         parameters.children = [
173             parameters.children[0],  # (2 what if this was actually long
174             body,
175             parameters.children[-1],  # )2
176         ]
177     if (
178         self._proc is not None
179         # has the child process finished?
180         and self._returncode is None
181         # the child process has finished, but the
182         # transport hasn't been notified yet?
183         and self._proc.poll() is None
184     ):
185         pass
186     # no newline before or after
187     short = [
188         # one
189         1,
190         # two
191         2,
192     ]
193
194     # no newline after
195     call(
196         arg1,
197         arg2,
198         """
199 short
200 """,
201         arg3=True,
202     )
203
204     ############################################################################
205
206     call2(
207         # short
208         arg1,
209         # but
210         arg2,
211         # multiline
212         """
213 short
214 """,
215         # yup
216         arg3=True,
217     )
218     lcomp = [
219         element for element in collection if element is not None  # yup  # yup  # right
220     ]
221     lcomp2 = [
222         # hello
223         element
224         # yup
225         for element in collection
226         # right
227         if element is not None
228     ]
229     lcomp3 = [
230         # This one is actually too long to fit in a single line.
231         element.split("\n", 1)[0]
232         # yup
233         for element in collection.select_elements()
234         # right
235         if element is not None
236     ]
237     while True:
238         if False:
239             continue
240
241     # and round and round we go
242     # and round and round we go
243
244     # let's return
245     return Node(
246         syms.simple_stmt,
247         [Node(statement, result), Leaf(token.NEWLINE, "\n")],  # FIXME: \r\n?
248     )
249
250
251 #######################
252 ### SECTION COMMENT ###
253 #######################
254
255
256 instruction()
257
258 # END COMMENTS
259 # MORE END COMMENTS