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

2045c93ffb88bdfc14603d3457fa250b8da0a4d4
[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             children[0],  # (1
39             body,
40             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 def inline_comments_in_brackets_ruin_everything():
165     if typedargslist:
166         parameters.children = [children[0], body, children[-1]]  # (1  # )1
167     else:
168         parameters.children = [
169             parameters.children[0],  # (2 what if this was actually long
170             body,
171             parameters.children[-1],  # )2
172         ]
173     if (
174         self._proc is not None
175         # has the child process finished?
176         and self._returncode is None
177         # the child process has finished, but the
178         # transport hasn't been notified yet?
179         and self._proc.poll() is None
180     ):
181         pass
182     # no newline before or after
183     short = [
184         # one
185         1,
186         # two
187         2,
188     ]
189
190     # no newline after
191     call(
192         arg1,
193         arg2,
194         """
195 short
196 """,
197         arg3=True,
198     )
199
200     ############################################################################
201
202     call2(
203         # short
204         arg1,
205         # but
206         arg2,
207         # multiline
208         """
209 short
210 """,
211         # yup
212         arg3=True,
213     )
214     lcomp = [
215         element for element in collection if element is not None  # yup  # yup  # right
216     ]
217     lcomp2 = [
218         # hello
219         element
220         # yup
221         for element in collection
222         # right
223         if element is not None
224     ]
225     lcomp3 = [
226         # This one is actually too long to fit in a single line.
227         element.split("\n", 1)[0]
228         # yup
229         for element in collection.select_elements()
230         # right
231         if element is not None
232     ]
233     while True:
234         if False:
235             continue
236
237             # and round and round we go
238         # and round and round we go
239
240     # let's return
241     return Node(
242         syms.simple_stmt,
243         [Node(statement, result), Leaf(token.NEWLINE, "\n")],  # FIXME: \r\n?
244     )
245
246
247 #######################
248 ### SECTION COMMENT ###
249 #######################
250
251
252 instruction()
253
254 # END COMMENTS
255 # MORE END COMMENTS