@@ -22,20 +22,47 @@ Currently, the following features are included in the preview style:
22
22
23
23
- ` always_one_newline_after_import ` : Always force one blank line after import
24
24
statements, except when the line after the import is a comment or an import statement
25
+ - ` wrap_long_dict_values_in_parens ` : Add parentheses around long values in dictionaries
26
+ ([ see below] ( labels/wrap-long-dict-values ) )
25
27
26
28
(labels/unstable-features)=
27
29
28
30
The unstable style additionally includes the following features:
29
31
30
32
- ` string_processing ` : split long string literals and related changes
31
33
([ see below] ( labels/string-processing ) )
32
- - ` wrap_long_dict_values_in_parens ` : add parentheses to long values in dictionaries
33
- ([ see below] ( labels/wrap-long-dict-values ) )
34
34
- ` multiline_string_handling ` : more compact formatting of expressions involving
35
35
multiline strings ([ see below] ( labels/multiline-string-handling ) )
36
36
- ` hug_parens_with_braces_and_square_brackets ` : more compact formatting of nested
37
37
brackets ([ see below] ( labels/hug-parens ) )
38
38
39
+ (labels/wrap-long-dict-values)=
40
+
41
+ ### Improved parentheses management in dicts
42
+
43
+ For dict literals with long values, they are now wrapped in parentheses. Unnecessary
44
+ parentheses are now removed. For example:
45
+
46
+ ``` python
47
+ my_dict = {
48
+ " a key in my dict" : a_very_long_variable
49
+ * and_a_very_long_function_call()
50
+ / 100000.0 ,
51
+ " another key" : (short_value),
52
+ }
53
+ ```
54
+
55
+ will be changed to:
56
+
57
+ ``` python
58
+ my_dict = {
59
+ " a key in my dict" : (
60
+ a_very_long_variable * and_a_very_long_function_call() / 100000.0
61
+ ),
62
+ " another key" : short_value,
63
+ }
64
+ ```
65
+
39
66
(labels/hug-parens)=
40
67
41
68
### Improved multiline dictionary and list indentation for sole function parameter
@@ -122,33 +149,6 @@ exceed the line length limit. Line continuation backslashes are converted into
122
149
parenthesized strings. Unnecessary parentheses are stripped. The stability and status of
123
150
this feature istracked in [ this issue] ( https://github.com/psf/black/issues/2188 ) .
124
151
125
- (labels/wrap-long-dict-values)=
126
-
127
- ### Improved parentheses management in dicts
128
-
129
- For dict literals with long values, they are now wrapped in parentheses. Unnecessary
130
- parentheses are now removed. For example:
131
-
132
- ``` python
133
- my_dict = {
134
- " a key in my dict" : a_very_long_variable
135
- * and_a_very_long_function_call()
136
- / 100000.0 ,
137
- " another key" : (short_value),
138
- }
139
- ```
140
-
141
- will be changed to:
142
-
143
- ``` python
144
- my_dict = {
145
- " a key in my dict" : (
146
- a_very_long_variable * and_a_very_long_function_call() / 100000.0
147
- ),
148
- " another key" : short_value,
149
- }
150
- ```
151
-
152
152
(labels/multiline-string-handling)=
153
153
154
154
### Improved multiline string handling
0 commit comments