File tree 1 file changed +49
-0
lines changed
docs/the_black_code_style
1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -62,3 +62,52 @@ plain strings. User-made splits are respected when they do not exceed the line l
62
62
limit. Line continuation backslashes are converted into parenthesized strings.
63
63
Unnecessary parentheses are stripped. The stability and status of this feature is
64
64
tracked in [ this issue] ( https://github.com/psf/black/issues/2188 ) .
65
+
66
+ ### Improved line breaks
67
+
68
+ For assignment expressions, it now prefers to split and wrap the right side of the
69
+ assignment instead of left side. For example:
70
+
71
+ ``` python
72
+ some_dict[
73
+ " with_a_long_key"
74
+ ] = some_looooooooong_module.some_looooooooooooooong_function_name(
75
+ first_argument, second_argument, third_argument
76
+ )
77
+ ```
78
+
79
+ will be changed to:
80
+
81
+ ``` python
82
+ some_dict[" with_a_long_key" ] = (
83
+ some_looooooooong_module.some_looooooooooooooong_function_name(
84
+ first_argument, second_argument, third_argument
85
+ )
86
+ )
87
+ ```
88
+
89
+ ### Improved parentheses management
90
+
91
+ For dict literals with long values, they are now wrapped in parentheses. Unnecessary
92
+ parentheses are now removed. For example:
93
+
94
+ ``` python
95
+ my_dict = {
96
+ my_dict = {
97
+ " a key in my dict" : a_very_long_variable
98
+ * and_a_very_long_function_call()
99
+ / 100000.0 ,
100
+ " another key" : (short_value),
101
+ }
102
+ ```
103
+
104
+ will be changed to:
105
+
106
+ ```python
107
+ my_dict = {
108
+ " a key in my dict" : (
109
+ a_very_long_variable * and_a_very_long_function_call() / 100000.0
110
+ ),
111
+ " another key" : short_value,
112
+ }
113
+ ```
You can’t perform that action at this time.
0 commit comments