Lone comprehensions without additional indentation #2830
Labels
F: linebreak
How should we split up lines?
R: duplicate
This issue or pull request already exists
T: style
What do we want Blackened code to look like?
Describe the style change
Comprehensions that are alone within a call (or similar) would be left without indentation.
Examples in the current Black style
Desired style
Additional context
A lot of functions take a single iterable as input, like
join
,list.extend
,dict.update
,numpy.stack
, ... For those, indenting the argument when it is a comprehension makes the code less readable IMO.A good example is creating 2d NumPy arrays:
becomes, after Black auto-format,
Another argument in favor of this change is that switching from a comprehension to a generator changes dramatically the formatting but not the meaning. For instance,
and
are formatted differently, even though they are quite similar semantically.
The text was updated successfully, but these errors were encountered: