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

Add DebugVisitor.show() to documentation under utility functions
[etc/vim.git] / tests / 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 f'trigger 3.6 mode'
10 # fmt: off
11 def func_no_args():
12   a; b; c
13   if True: raise RuntimeError
14   if False: ...
15   for i in range(10):
16     print(i)
17     continue
18   exec("new-style exec", {}, {})
19   return None
20 async def coroutine(arg, exec=False):
21  "Single-line docstring. Multiline is harder to reformat."
22  async with some_connection() as conn:
23      await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)
24  await asyncio.sleep(1)
25 @asyncio.coroutine
26 @some_decorator(
27 with_args=True,
28 many_args=[1,2,3]
29 )
30 def function_signature_stress_test(number:int,no_annotation=None,text:str="default",* ,debug:bool=False,**kwargs) -> str:
31  return text[number:-1]
32 # fmt: on
33 def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r''):
34  offset = attr.ib(default=attr.Factory( lambda: _r.uniform(10000, 200000)))
35  assert task._cancel_stack[:len(old_stack)] == old_stack
36 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''): ...
37 def spaces2(result= _core.Value(None)):
38  ...
39 def example(session):
40     # fmt: off
41     result = session\
42         .query(models.Customer.id)\
43         .filter(models.Customer.account_id == account_id,
44                 models.Customer.email == email_address)\
45         .order_by(models.Customer.id.asc())\
46         .all()
47     # fmt: on
48 def long_lines():
49     if True:
50         typedargslist.extend(
51             gen_annotated_params(ast_args.kwonlyargs, ast_args.kw_defaults, parameters, implicit_default=True)
52         )
53     _type_comment_re = re.compile(
54         r"""
55         ^
56         [\t ]*
57         \#[ ]type:[ ]*
58         (?P<type>
59             [^#\t\n]+?
60         )
61         (?<!ignore)     # note: this will force the non-greedy + in <type> to match
62                         # a trailing space which is why we need the silliness below
63         (?<!ignore[ ]{1})(?<!ignore[ ]{2})(?<!ignore[ ]{3})(?<!ignore[ ]{4})
64         (?<!ignore[ ]{5})(?<!ignore[ ]{6})(?<!ignore[ ]{7})(?<!ignore[ ]{8})
65         (?<!ignore[ ]{9})(?<!ignore[ ]{10})
66         [\t ]*
67         (?P<nl>
68             (?:\#[^\n]*)?
69             \n?
70         )
71         $
72         """, re.MULTILINE | re.VERBOSE
73     )
74
75 # output
76
77
78 #!/usr/bin/env python3
79 import asyncio
80 import sys
81
82 from third_party import X, Y, Z
83
84 from library import some_connection, some_decorator
85
86 f'trigger 3.6 mode'
87 # fmt: off
88 def func_no_args():
89   a; b; c
90   if True: raise RuntimeError
91   if False: ...
92   for i in range(10):
93     print(i)
94     continue
95   exec("new-style exec", {}, {})
96   return None
97 async def coroutine(arg, exec=False):
98  "Single-line docstring. Multiline is harder to reformat."
99  async with some_connection() as conn:
100      await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)
101  await asyncio.sleep(1)
102 @asyncio.coroutine
103 @some_decorator(
104 with_args=True,
105 many_args=[1,2,3]
106 )
107 def function_signature_stress_test(number:int,no_annotation=None,text:str="default",* ,debug:bool=False,**kwargs) -> str:
108  return text[number:-1]
109 # fmt: on
110
111
112 def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r''):
113     offset = attr.ib(default=attr.Factory(lambda: _r.uniform(10000, 200000)))
114     assert task._cancel_stack[:len(old_stack)] == old_stack
115
116
117 def spaces_types(
118     a: int = 1,
119     b: tuple = (),
120     c: list = [],
121     d: dict = {},
122     e: bool = True,
123     f: int = -1,
124     g: int = 1 if False else 2,
125     h: str = "",
126     i: str = r'',
127 ):
128     ...
129
130
131 def spaces2(result=_core.Value(None)):
132     ...
133
134
135 def example(session):
136     # fmt: off
137     result = session\
138         .query(models.Customer.id)\
139         .filter(models.Customer.account_id == account_id,
140                 models.Customer.email == email_address)\
141         .order_by(models.Customer.id.asc())\
142         .all()
143     # fmt: on
144
145
146 def long_lines():
147     if True:
148         typedargslist.extend(
149             gen_annotated_params(
150                 ast_args.kwonlyargs,
151                 ast_args.kw_defaults,
152                 parameters,
153                 implicit_default=True,
154             )
155         )
156     _type_comment_re = re.compile(
157         r"""
158         ^
159         [\t ]*
160         \#[ ]type:[ ]*
161         (?P<type>
162             [^#\t\n]+?
163         )
164         (?<!ignore)     # note: this will force the non-greedy + in <type> to match
165                         # a trailing space which is why we need the silliness below
166         (?<!ignore[ ]{1})(?<!ignore[ ]{2})(?<!ignore[ ]{3})(?<!ignore[ ]{4})
167         (?<!ignore[ ]{5})(?<!ignore[ ]{6})(?<!ignore[ ]{7})(?<!ignore[ ]{8})
168         (?<!ignore[ ]{9})(?<!ignore[ ]{10})
169         [\t ]*
170         (?P<nl>
171             (?:\#[^\n]*)?
172             \n?
173         )
174         $
175         """,
176         re.MULTILINE | re.VERBOSE,
177     )