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

Migrate mypy config to pyproject.toml (#3936)
[etc/vim.git] / tests / data / cases / conditional_expression.py
1 # flags: --preview
2 long_kwargs_single_line = my_function(
3     foo="test, this is a sample value",
4     bar=some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz,
5     baz="hello, this is a another value",
6 )
7
8 multiline_kwargs_indented = my_function(
9     foo="test, this is a sample value",
10     bar=some_long_value_name_foo_bar_baz
11     if some_boolean_variable
12     else some_fallback_value_foo_bar_baz,
13     baz="hello, this is a another value",
14 )
15
16 imploding_kwargs = my_function(
17     foo="test, this is a sample value",
18     bar=a
19     if foo
20     else b,
21     baz="hello, this is a another value",
22 )
23
24 imploding_line = (
25     1
26     if 1 + 1 == 2
27     else 0
28 )
29
30 exploding_line = "hello this is a slightly long string" if some_long_value_name_foo_bar_baz else "this one is a little shorter"
31
32 positional_argument_test(some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz)
33
34 def weird_default_argument(x=some_long_value_name_foo_bar_baz
35         if SOME_CONSTANT
36         else some_fallback_value_foo_bar_baz):
37     pass
38
39 nested = "hello this is a slightly long string" if (some_long_value_name_foo_bar_baz if
40                                                     nesting_test_expressions else some_fallback_value_foo_bar_baz) \
41     else "this one is a little shorter"
42
43 generator_expression = (
44     some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz for some_boolean_variable in some_iterable
45 )
46
47
48 def limit_offset_sql(self, low_mark, high_mark):
49     """Return LIMIT/OFFSET SQL clause."""
50     limit, offset = self._get_limit_offset_params(low_mark, high_mark)
51     return " ".join(
52         sql
53         for sql in (
54             "LIMIT %d" % limit if limit else None,
55             ("OFFSET %d" % offset) if offset else None,
56         )
57         if sql
58     )
59
60
61 def something():
62     clone._iterable_class = (
63         NamedValuesListIterable
64         if named
65         else FlatValuesListIterable
66         if flat
67         else ValuesListIterable
68     )
69
70 # output
71
72 long_kwargs_single_line = my_function(
73     foo="test, this is a sample value",
74     bar=(
75         some_long_value_name_foo_bar_baz
76         if some_boolean_variable
77         else some_fallback_value_foo_bar_baz
78     ),
79     baz="hello, this is a another value",
80 )
81
82 multiline_kwargs_indented = my_function(
83     foo="test, this is a sample value",
84     bar=(
85         some_long_value_name_foo_bar_baz
86         if some_boolean_variable
87         else some_fallback_value_foo_bar_baz
88     ),
89     baz="hello, this is a another value",
90 )
91
92 imploding_kwargs = my_function(
93     foo="test, this is a sample value",
94     bar=a if foo else b,
95     baz="hello, this is a another value",
96 )
97
98 imploding_line = 1 if 1 + 1 == 2 else 0
99
100 exploding_line = (
101     "hello this is a slightly long string"
102     if some_long_value_name_foo_bar_baz
103     else "this one is a little shorter"
104 )
105
106 positional_argument_test(
107     some_long_value_name_foo_bar_baz
108     if some_boolean_variable
109     else some_fallback_value_foo_bar_baz
110 )
111
112
113 def weird_default_argument(
114     x=(
115         some_long_value_name_foo_bar_baz
116         if SOME_CONSTANT
117         else some_fallback_value_foo_bar_baz
118     ),
119 ):
120     pass
121
122
123 nested = (
124     "hello this is a slightly long string"
125     if (
126         some_long_value_name_foo_bar_baz
127         if nesting_test_expressions
128         else some_fallback_value_foo_bar_baz
129     )
130     else "this one is a little shorter"
131 )
132
133 generator_expression = (
134     (
135         some_long_value_name_foo_bar_baz
136         if some_boolean_variable
137         else some_fallback_value_foo_bar_baz
138     )
139     for some_boolean_variable in some_iterable
140 )
141
142
143 def limit_offset_sql(self, low_mark, high_mark):
144     """Return LIMIT/OFFSET SQL clause."""
145     limit, offset = self._get_limit_offset_params(low_mark, high_mark)
146     return " ".join(
147         sql
148         for sql in (
149             "LIMIT %d" % limit if limit else None,
150             ("OFFSET %d" % offset) if offset else None,
151         )
152         if sql
153     )
154
155
156 def something():
157     clone._iterable_class = (
158         NamedValuesListIterable
159         if named
160         else FlatValuesListIterable if flat else ValuesListIterable
161     )