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

Fix string normalization eating all backslashes above 3
[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 def example(session):
44     # fmt: off
45     result = session\
46         .query(models.Customer.id)\
47         .filter(models.Customer.account_id == account_id,
48                 models.Customer.email == email_address)\
49         .order_by(models.Customer.id.asc())\
50         .all()
51     # fmt: on
52 def long_lines():
53     if True:
54         typedargslist.extend(
55             gen_annotated_params(ast_args.kwonlyargs, ast_args.kw_defaults, parameters, implicit_default=True)
56         )
57         # fmt: off
58         a = (
59             unnecessary_bracket()
60         )
61         # fmt: on
62     _type_comment_re = re.compile(
63         r"""
64         ^
65         [\t ]*
66         \#[ ]type:[ ]*
67         (?P<type>
68             [^#\t\n]+?
69         )
70         (?<!ignore)     # note: this will force the non-greedy + in <type> to match
71                         # a trailing space which is why we need the silliness below
72         (?<!ignore[ ]{1})(?<!ignore[ ]{2})(?<!ignore[ ]{3})(?<!ignore[ ]{4})
73         (?<!ignore[ ]{5})(?<!ignore[ ]{6})(?<!ignore[ ]{7})(?<!ignore[ ]{8})
74         (?<!ignore[ ]{9})(?<!ignore[ ]{10})
75         [\t ]*
76         (?P<nl>
77             (?:\#[^\n]*)?
78             \n?
79         )
80         $
81         """, # fmt: off
82         re.MULTILINE | re.VERBOSE
83     )
84     # fmt: on
85 def single_literal_yapf_disable():
86     """Black does not support this."""
87     BAZ = {
88         (1, 2, 3, 4),
89         (5, 6, 7, 8),
90         (9, 10, 11, 12),
91     }  # yapf: disable
92 # fmt: off
93 # No formatting to the end of the file
94 l=[1,2,3]
95 d={'a':1,
96    'b':2}
97
98 # output
99
100
101 #!/usr/bin/env python3
102 import asyncio
103 import sys
104
105 from third_party import X, Y, Z
106
107 from library import some_connection, some_decorator
108
109 # fmt: off
110 from third_party import (X,
111                          Y, Z)
112 # fmt: on
113 f"trigger 3.6 mode"
114 # fmt: off
115 def func_no_args():
116   a; b; c
117   if True: raise RuntimeError
118   if False: ...
119   for i in range(10):
120     print(i)
121     continue
122   exec('new-style exec', {}, {})
123   return None
124 async def coroutine(arg, exec=False):
125  'Single-line docstring. Multiline is harder to reformat.'
126  async with some_connection() as conn:
127      await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)
128  await asyncio.sleep(1)
129 @asyncio.coroutine
130 @some_decorator(
131 with_args=True,
132 many_args=[1,2,3]
133 )
134 def function_signature_stress_test(number:int,no_annotation=None,text:str='default',* ,debug:bool=False,**kwargs) -> str:
135  return text[number:-1]
136 # fmt: on
137 def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r""):
138     offset = attr.ib(default=attr.Factory(lambda: _r.uniform(10000, 200000)))
139     assert task._cancel_stack[: len(old_stack)] == old_stack
140
141
142 def spaces_types(
143     a: int = 1,
144     b: tuple = (),
145     c: list = [],
146     d: dict = {},
147     e: bool = True,
148     f: int = -1,
149     g: int = 1 if False else 2,
150     h: str = "",
151     i: str = r"",
152 ):
153     ...
154
155
156 def spaces2(result=_core.Value(None)):
157     ...
158
159
160 def example(session):
161     # fmt: off
162     result = session\
163         .query(models.Customer.id)\
164         .filter(models.Customer.account_id == account_id,
165                 models.Customer.email == email_address)\
166         .order_by(models.Customer.id.asc())\
167         .all()
168     # fmt: on
169
170
171 def long_lines():
172     if True:
173         typedargslist.extend(
174             gen_annotated_params(
175                 ast_args.kwonlyargs,
176                 ast_args.kw_defaults,
177                 parameters,
178                 implicit_default=True,
179             )
180         )
181         # fmt: off
182         a = (
183             unnecessary_bracket()
184         )
185         # fmt: on
186     _type_comment_re = re.compile(
187         r"""
188         ^
189         [\t ]*
190         \#[ ]type:[ ]*
191         (?P<type>
192             [^#\t\n]+?
193         )
194         (?<!ignore)     # note: this will force the non-greedy + in <type> to match
195                         # a trailing space which is why we need the silliness below
196         (?<!ignore[ ]{1})(?<!ignore[ ]{2})(?<!ignore[ ]{3})(?<!ignore[ ]{4})
197         (?<!ignore[ ]{5})(?<!ignore[ ]{6})(?<!ignore[ ]{7})(?<!ignore[ ]{8})
198         (?<!ignore[ ]{9})(?<!ignore[ ]{10})
199         [\t ]*
200         (?P<nl>
201             (?:\#[^\n]*)?
202             \n?
203         )
204         $
205         """,  # fmt: off
206         re.MULTILINE | re.VERBOSE,
207     )
208     # fmt: on
209
210
211 def single_literal_yapf_disable():
212     """Black does not support this."""
213     BAZ = {(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12)}  # yapf: disable
214
215
216 # fmt: off
217 # No formatting to the end of the file
218 l=[1,2,3]
219 d={'a':1,
220    'b':2}