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

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