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

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