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

Fix tests after introducing --check
[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
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
75 def func_no_args():
76     a
77     b
78     c
79     if True:
80         raise RuntimeError
81
82     if False:
83         ...
84     for i in range(10):
85         print(i)
86         continue
87
88     return None
89
90
91 async def coroutine(arg):
92     "Single-line docstring. Multiline is harder to reformat."
93     async with some_connection() as conn:
94         await conn.do_what_i_mean('SELECT bobby, tables FROM xkcd', timeout=2)
95     await asyncio.sleep(1)
96
97
98 @asyncio.coroutine
99 @some_decorator(with_args=True, many_args=[1, 2, 3])
100 def function_signature_stress_test(
101     number: int,
102     no_annotation=None,
103     text: str = "default",
104     *,
105     debug: bool = False,
106     **kwargs,
107 ) -> str:
108     return text[number:-1]
109
110
111 def spaces(a=1, b=(), c=[], d={}, e=True, f=-1, g=1 if False else 2, h="", i=r''):
112     offset = attr.ib(default=attr.Factory(lambda: _r.uniform(10000, 200000)))
113     assert task._cancel_stack[:len(old_stack)] == old_stack
114
115
116 def spaces2(result=_core.Value(None)):
117     ...
118
119
120 def long_lines():
121     if True:
122         typedargslist.extend(
123             gen_annotated_params(
124                 ast_args.kwonlyargs,
125                 ast_args.kw_defaults,
126                 parameters,
127                 implicit_default=True,
128             )
129         )
130     _type_comment_re = re.compile(
131         r"""
132         ^
133         [\t ]*
134         \#[ ]type:[ ]*
135         (?P<type>
136             [^#\t\n]+?
137         )
138         (?<!ignore)     # note: this will force the non-greedy + in <type> to match
139                         # a trailing space which is why we need the silliness below
140         (?<!ignore[ ]{1})(?<!ignore[ ]{2})(?<!ignore[ ]{3})(?<!ignore[ ]{4})
141         (?<!ignore[ ]{5})(?<!ignore[ ]{6})(?<!ignore[ ]{7})(?<!ignore[ ]{8})
142         (?<!ignore[ ]{9})(?<!ignore[ ]{10})
143         [\t ]*
144         (?P<nl>
145             (?:\#[^\n]*)?
146             \n?
147         )
148         $
149         """,
150         re.MULTILINE | re.VERBOSE,
151     )