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

release process: formalize the changelog template (#2837)
[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 (
93         a
94         == {
95             "a": 1,
96             "b": 2,
97             "c": 3,
98             "d": 4,
99             "e": 5,
100             "f": 6,
101             "g": 7,
102             "h": 8,
103         }["a"]
104     ):
105         pass
106
107
108 def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> Set[
109     "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
110 ]:
111     json = {
112         "k": {
113             "k2": {
114                 "k3": [
115                     1,
116                 ]
117             }
118         }
119     }
120
121
122 # The type annotation shouldn't get a trailing comma since that would change its type.
123 # Relevant bug report: https://github.com/psf/black/issues/2381.
124 def some_function_with_a_really_long_name() -> (
125     returning_a_deeply_nested_import_of_a_type_i_suppose
126 ):
127     pass
128
129
130 def some_method_with_a_really_long_name(
131     very_long_parameter_so_yeah: str, another_long_parameter: int
132 ) -> (
133     another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not
134 ):
135     pass
136
137
138 def func() -> (
139     also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black(
140         this_shouldn_t_get_a_trailing_comma_too
141     )
142 ):
143     pass
144
145
146 def func() -> (
147     (
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 ):
153     pass