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:
# YAPF
<p align="center">
<a href="https://badge.fury.io/py/yapf"><img alt="PyPI Version" src="https://badge.fury.io/py/yapf.svg"></a>
<a href="https://github.com/google/yapf/actions/workflows/ci.yml"><img alt="Build Status" src="https://github.com/google/yapf/actions/workflows/ci.yml/badge.svg"></a>
<a href="https://github.com/google/yapf/actions/workflows/pre-commit.yml"><img alt="Actions Status" src="https://github.com/google/yapf/actions/workflows/pre-commit.yml/badge.svg"></a>
<a href="https://coveralls.io/github/google/yapf?branch=main"><img alt="Coverage Status" src="https://coveralls.io/repos/github/google/yapf/badge.svg?branch=main"></a>
</p>
## Introduction
YAPF is a Python formatter based on [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html)
(developed by Daniel Jasper). In essence, the algorithm takes the code and
calculates the best formatting that conforms to the configured style. It takes
away a lot of the drudgery of maintaining your code.
The ultimate goal is that the code YAPF produces is as good as the code that a
programmer would write if they were following the style guide.
This file has been truncated. show original
Perhaps for of these can achiece the layout you’d like.