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

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