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

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