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

Re-export black.Mode (#3875)
[etc/vim.git] / tests / data / simple_cases / 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
53 # Make sure inner one-element tuple won't explode
54 some_module.some_function(
55     argument1, (one_element_tuple,), argument4, argument5, argument6
56 )
57
58 # Inner trailing comma causes outer to explode
59 some_module.some_function(
60     argument1, (one, two,), argument4, argument5, argument6
61 )
62
63 # output
64
65 def f(
66     a,
67 ):
68     d = {
69         "key": "value",
70     }
71     tup = (1,)
72
73
74 def f2(
75     a,
76     b,
77 ):
78     d = {
79         "key": "value",
80         "key2": "value2",
81     }
82     tup = (
83         1,
84         2,
85     )
86
87
88 def f(
89     a: int = 1,
90 ):
91     call(
92         arg={
93             "explode": "this",
94         }
95     )
96     call2(
97         arg=[1, 2, 3],
98     )
99     x = {
100         "a": 1,
101         "b": 2,
102     }["a"]
103     if (
104         a
105         == {
106             "a": 1,
107             "b": 2,
108             "c": 3,
109             "d": 4,
110             "e": 5,
111             "f": 6,
112             "g": 7,
113             "h": 8,
114         }["a"]
115     ):
116         pass
117
118
119 def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> (
120     Set["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]
121 ):
122     json = {
123         "k": {
124             "k2": {
125                 "k3": [
126                     1,
127                 ]
128             }
129         }
130     }
131
132
133 # The type annotation shouldn't get a trailing comma since that would change its type.
134 # Relevant bug report: https://github.com/psf/black/issues/2381.
135 def some_function_with_a_really_long_name() -> (
136     returning_a_deeply_nested_import_of_a_type_i_suppose
137 ):
138     pass
139
140
141 def some_method_with_a_really_long_name(
142     very_long_parameter_so_yeah: str, another_long_parameter: int
143 ) -> another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not:
144     pass
145
146
147 def func() -> (
148     also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
149         this_shouldn_t_get_a_trailing_comma_too
150     )
151 ):
152     pass
153
154
155 def func() -> (
156     also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
157         this_shouldn_t_get_a_trailing_comma_too
158     )
159 ):
160     pass
161
162
163 # Make sure inner one-element tuple won't explode
164 some_module.some_function(
165     argument1, (one_element_tuple,), argument4, argument5, argument6
166 )
167
168 # Inner trailing comma causes outer to explode
169 some_module.some_function(
170     argument1,
171     (
172         one,
173         two,
174     ),
175     argument4,
176     argument5,
177     argument6,
178 )