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

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