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

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