request: Line break before binary operators
stephen-huan opened this issue · comments
Stephen Huan commented
Currently
using JuliaFormatter: format_text
text = """
income = gross_wages +
taxable_interest +
(dividends - qualified_dividends) -
ira_deduction -
student_loan_interest
y = true && true && true && false && false
"""
println(format_text(text; margin=30))
formats to
income =
gross_wages +
taxable_interest +
(dividends - qualified_dividends) -
ira_deduction -
student_loan_interest
y =
true &&
true &&
true &&
false &&
false
Is it possible to instead break the line before the binary operator as
income =
gross_wages
+ taxable_interest
+ (dividends - qualified_dividends)
- ira_deduction
- student_loan_interest
y = (
true
&& true
&& true
&& false
&& false
)
as black and PEP 8 recommend for readability?
The documentation says
Binary operations and conditionals are nested back-to-front.
so I'm not sure how difficult this would be to implement.
Note that without the parentheses
y =
true
&& true
&& true
&& false
&& false
is not valid Julia syntax so I'd also recommend an option to also add parentheses (#709) to
income = (
gross_wages
+ taxable_interest
+ (dividends - qualified_dividends)
- ira_deduction
- student_loan_interest
)
for consistency.
Thanks!