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

373e5c7090396e994b19e2048271ded0aad5bc5a
[etc/vim.git] / tests / data / fmtonoff.py
1 #!/usr/bin/env python3
2 import asyncio
3 import sys
4
5 from third_party import X, Y, Z
6
7 from library import some_connection, \
8                     some_decorator
9 # fmt: off
10 from third_party import (X,
11                          Y, Z)
12 # fmt: on
13 f'trigger 3.6 mode'
14 # fmt: off
15 def func_no_args():
16   a; b; c
17   if True: raise RuntimeError
18   if False: ...
19   for i in range(10):
20     print(i)
21     continue
22   exec('new-style exec', {}, {})
23   return None
24 async def coroutine(arg, exec=False):
25  'Single-line docstring. Multiline is harder to reformat.'
26  async with some_connection() as conn:
27      await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)
28  await asyncio.sleep(1)
29 @asyncio.coroutine
30 @some_decorator(
31 with_args=True,
32 many_args=[1,2,3]
33 )
34 def function_signature_stress_test(number:int,no_annotation=None,text:str='default',* ,debug:bool=False,**kwargs) -> str:
35  return text[number:-1]
36 # fmt: on
37 def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r''):
38  offset = attr.ib(default=attr.Factory( lambda: _r.uniform(10000, 200000)))
39  assert task._cancel_stack[:len(old_stack)] == old_stack
40 def spaces_types(a: int = 1, b: tuple = (), c: list = [], d: dict = {}, e: bool = True, f: int = -1, g: int = 1 if False else 2, h: str = "", i: str = r''): ...
41 def spaces2(result= _core.Value(None)):
42  ...
43 something = {
44     # fmt: off
45     key: 'value',
46 }
47 def example(session):
48     # fmt: off
49     result = session\
50         .query(models.Customer.id)\
51         .filter(models.Customer.account_id == account_id,
52                 models.Customer.email == email_address)\
53         .order_by(models.Customer.id.asc())\
54         .all()
55     # fmt: on
56 def long_lines():
57     if True:
58         typedargslist.extend(
59             gen_annotated_params(ast_args.kwonlyargs, ast_args.kw_defaults, parameters, implicit_default=True)
60         )
61         # fmt: off
62         a = (
63             unnecessary_bracket()
64         )
65         # fmt: on
66     _type_comment_re = re.compile(
67         r"""
68         ^
69         [\t ]*
70         \#[ ]type:[ ]*
71         (?P<type>
72             [^#\t\n]+?
73         )
74         (?<!ignore)     # note: this will force the non-greedy + in <type> to match
75                         # a trailing space which is why we need the silliness below
76         (?<!ignore[ ]{1})(?<!ignore[ ]{2})(?<!ignore[ ]{3})(?<!ignore[ ]{4})
77         (?<!ignore[ ]{5})(?<!ignore[ ]{6})(?<!ignore[ ]{7})(?<!ignore[ ]{8})
78         (?<!ignore[ ]{9})(?<!ignore[ ]{10})
79         [\t ]*
80         (?P<nl>
81             (?:\#[^\n]*)?
82             \n?
83         )
84         $
85         """,
86         # fmt: off
87         re.MULTILINE|re.VERBOSE
88         # fmt: on
89     )
90 def single_literal_yapf_disable():
91     """Black does not support this."""
92     BAZ = {
93         (1, 2, 3, 4),
94         (5, 6, 7, 8),
95         (9, 10, 11, 12),
96     }  # yapf: disable
97 cfg.rule(
98     "Default", "address",
99     xxxx_xxxx=["xxx-xxxxxx-xxxxxxxxxx"],
100     xxxxxx="xx_xxxxx", xxxxxxx="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
101     xxxxxxxxx_xxxx=True, xxxxxxxx_xxxxxxxxxx=False,
102     xxxxxx_xxxxxx=2, xxxxxx_xxxxx_xxxxxxxx=70, xxxxxx_xxxxxx_xxxxx=True,
103     # fmt: off
104     xxxxxxx_xxxxxxxxxxxx={
105         "xxxxxxxx": {
106             "xxxxxx": False,
107             "xxxxxxx": False,
108             "xxxx_xxxxxx": "xxxxx",
109         },
110         "xxxxxxxx-xxxxx": {
111             "xxxxxx": False,
112             "xxxxxxx": True,
113             "xxxx_xxxxxx": "xxxxxx",
114         },
115     },
116     # fmt: on
117     xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5
118 )
119 # fmt: off
120 # No formatting to the end of the file
121 l=[1,2,3]
122 d={'a':1,
123    'b':2}
124
125 # output
126
127
128 #!/usr/bin/env python3
129 import asyncio
130 import sys
131
132 from third_party import X, Y, Z
133
134 from library import some_connection, some_decorator
135
136 # fmt: off
137 from third_party import (X,
138                          Y, Z)
139 # fmt: on
140 f"trigger 3.6 mode"
141 # fmt: off
142 def func_no_args():
143   a; b; c
144   if True: raise RuntimeError
145   if False: ...
146   for i in range(10):
147     print(i)
148     continue
149   exec('new-style exec', {}, {})
150   return None
151 async def coroutine(arg, exec=False):
152  'Single-line docstring. Multiline is harder to reformat.'
153  async with some_connection() as conn:
154      await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)
155  await asyncio.sleep(1)
156 @asyncio.coroutine
157 @some_decorator(
158 with_args=True,
159 many_args=[1,2,3]
160 )
161 def function_signature_stress_test(number:int,no_annotation=None,text:str='default',* ,debug:bool=False,**kwargs) -> str:
162  return text[number:-1]
163 # fmt: on
164 def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r""):
165     offset = attr.ib(default=attr.Factory(lambda: _r.uniform(10000, 200000)))
166     assert task._cancel_stack[: len(old_stack)] == old_stack
167
168
169 def spaces_types(
170     a: int = 1,
171     b: tuple = (),
172     c: list = [],
173     d: dict = {},
174     e: bool = True,
175     f: int = -1,
176     g: int = 1 if False else 2,
177     h: str = "",
178     i: str = r"",
179 ):
180     ...
181
182
183 def spaces2(result=_core.Value(None)):
184     ...
185
186
187 something = {
188     # fmt: off
189     key: 'value',
190 }
191
192
193 def example(session):
194     # fmt: off
195     result = session\
196         .query(models.Customer.id)\
197         .filter(models.Customer.account_id == account_id,
198                 models.Customer.email == email_address)\
199         .order_by(models.Customer.id.asc())\
200         .all()
201     # fmt: on
202
203
204 def long_lines():
205     if True:
206         typedargslist.extend(
207             gen_annotated_params(
208                 ast_args.kwonlyargs,
209                 ast_args.kw_defaults,
210                 parameters,
211                 implicit_default=True,
212             )
213         )
214         # fmt: off
215         a = (
216             unnecessary_bracket()
217         )
218         # fmt: on
219     _type_comment_re = re.compile(
220         r"""
221         ^
222         [\t ]*
223         \#[ ]type:[ ]*
224         (?P<type>
225             [^#\t\n]+?
226         )
227         (?<!ignore)     # note: this will force the non-greedy + in <type> to match
228                         # a trailing space which is why we need the silliness below
229         (?<!ignore[ ]{1})(?<!ignore[ ]{2})(?<!ignore[ ]{3})(?<!ignore[ ]{4})
230         (?<!ignore[ ]{5})(?<!ignore[ ]{6})(?<!ignore[ ]{7})(?<!ignore[ ]{8})
231         (?<!ignore[ ]{9})(?<!ignore[ ]{10})
232         [\t ]*
233         (?P<nl>
234             (?:\#[^\n]*)?
235             \n?
236         )
237         $
238         """,
239         # fmt: off
240         re.MULTILINE|re.VERBOSE
241         # fmt: on
242     )
243
244
245 def single_literal_yapf_disable():
246     """Black does not support this."""
247     BAZ = {(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12)}  # yapf: disable
248
249
250 cfg.rule(
251     "Default",
252     "address",
253     xxxx_xxxx=["xxx-xxxxxx-xxxxxxxxxx"],
254     xxxxxx="xx_xxxxx",
255     xxxxxxx="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
256     xxxxxxxxx_xxxx=True,
257     xxxxxxxx_xxxxxxxxxx=False,
258     xxxxxx_xxxxxx=2,
259     xxxxxx_xxxxx_xxxxxxxx=70,
260     xxxxxx_xxxxxx_xxxxx=True,
261     # fmt: off
262     xxxxxxx_xxxxxxxxxxxx={
263         "xxxxxxxx": {
264             "xxxxxx": False,
265             "xxxxxxx": False,
266             "xxxx_xxxxxx": "xxxxx",
267         },
268         "xxxxxxxx-xxxxx": {
269             "xxxxxx": False,
270             "xxxxxxx": True,
271             "xxxx_xxxxxx": "xxxxxx",
272         },
273     },
274     # fmt: on
275     xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5,
276 )
277 # fmt: off
278 # No formatting to the end of the file
279 l=[1,2,3]
280 d={'a':1,
281    'b':2}