How to format mathematical expressions?

For the example given above where Black produces

result = 2 * x**2 + 3 * x ** (2 / 3)

I don’t like how + and * are given the same spacing. My preference is to add parentheses:

result = (2 * x**2) + (3 * x**(2 / 3))

I also would prefer to not add whitespace for exponentiation to a parenthesised expression (as on the RHS here), but I don’t feel as strongly about that.

Black is very opinionated and has nearly no tuning at all.

I prefer yapf myself. It has many knobs. See:

Perhaps for of these can achiece the layout you’d like.