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

vim: Parse skip_magic_trailing_comma from pyproject.toml (#2613)
[etc/vim.git] / tests / data / function_trailing_comma.py
1 def f(a,):
2     d = {'key': 'value',}
3     tup = (1,)
4
5 def f2(a,b,):
6     d = {'key': 'value', 'key2': 'value2',}
7     tup = (1,2,)
8
9 def f(a:int=1,):
10     call(arg={'explode': 'this',})
11     call2(arg=[1,2,3],)
12     x = {
13         "a": 1,
14         "b": 2,
15     }["a"]
16     if a == {"a": 1,"b": 2,"c": 3,"d": 4,"e": 5,"f": 6,"g": 7,"h": 8,}["a"]:
17         pass
18
19 def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> Set[
20     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
21 ]:
22     json = {"k": {"k2": {"k3": [1,]}}}
23
24
25
26 # The type annotation shouldn't get a trailing comma since that would change its type.
27 # Relevant bug report: https://github.com/psf/black/issues/2381.
28 def some_function_with_a_really_long_name() -> (
29     returning_a_deeply_nested_import_of_a_type_i_suppose
30 ):
31     pass
32
33
34 def some_method_with_a_really_long_name(very_long_parameter_so_yeah: str, another_long_parameter: int) -> (
35     another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not
36 ):
37     pass
38
39
40 def func() -> (
41     also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(this_shouldn_t_get_a_trailing_comma_too)
42 ):
43     pass
44
45
46 def func() -> ((also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
47         this_shouldn_t_get_a_trailing_comma_too
48     ))
49 ):
50     pass
51
52 # output
53
54 def f(
55     a,
56 ):
57     d = {
58         "key": "value",
59     }
60     tup = (1,)
61
62
63 def f2(
64     a,
65     b,
66 ):
67     d = {
68         "key": "value",
69         "key2": "value2",
70     }
71     tup = (
72         1,
73         2,
74     )
75
76
77 def f(
78     a: int = 1,
79 ):
80     call(
81         arg={
82             "explode": "this",
83         }
84     )
85     call2(
86         arg=[1, 2, 3],
87     )
88     x = {
89         "a": 1,
90         "b": 2,
91     }["a"]
92     if a == {
93         "a": 1,
94         "b": 2,
95         "c": 3,
96         "d": 4,
97         "e": 5,
98         "f": 6,
99         "g": 7,
100         "h": 8,
101     }["a"]:
102         pass
103
104
105 def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> Set[
106     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
107 ]:
108     json = {
109         "k": {
110             "k2": {
111                 "k3": [
112                     1,
113                 ]
114             }
115         }
116     }
117
118
119 # The type annotation shouldn't get a trailing comma since that would change its type.
120 # Relevant bug report: https://github.com/psf/black/issues/2381.
121 def some_function_with_a_really_long_name() -> (
122     returning_a_deeply_nested_import_of_a_type_i_suppose
123 ):
124     pass
125
126
127 def some_method_with_a_really_long_name(
128     very_long_parameter_so_yeah: str, another_long_parameter: int
129 ) -> (
130     another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not
131 ):
132     pass
133
134
135 def func() -> (
136     also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
137         this_shouldn_t_get_a_trailing_comma_too
138     )
139 ):
140     pass
141
142
143 def func() -> (
144     (
145         also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
146             this_shouldn_t_get_a_trailing_comma_too
147         )
148     )
149 ):
150     pass