Generalized the ending comma heuristic to subscripts
This commit ensures that
G[A, B, C,]
is split in a similar way to
[A, B, C,]
i.e.
G[
A,
B,
C,
]
instead of
G[A, B,
C,]
assuming A, B and C do not fit on a single line.
Long subscript expressions often occur when instantiating generic classes,
and having YAPF reformat them to a more readable multi-line variant seems
like a "good thing".
---
Note that the heuristic is not perfect and in particular could produce
unexpected/verbose outputs when one of the items is itself a list with
an ending comma, e.g.
G[[A,], B, C,]
is reformatted to
G[
[
A,
],
B,
C,
]
where G could be typing.Callable.
4 files changed