-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Describe the style change
If inline comments have been aligned, that has most likely been done for a reason and breaking the alignment is likely to make the code worse. As an example, we have this code in our project:
TypeHint = Union[
type, # Actual type.
str, # Type name or alias.
UnionType, # Union syntax (e.g. `int | float`).
'tuple[TypeHint, ...]' # Tuple of type hints. Behaves like a union.
]
Examples in the current Black style
Currently the above example is formatted like this:
TypeHint = Union[
type, # Actual type.
str, # Type name or alias.
UnionType, # Union syntax (e.g. `int | float`).
'tuple[TypeHint, ...]', # Tuple of type hints. Behaves like a union.
]
Desired style
I'd prefer the original formatting of comments to be preserved. Well, I would be fine if there would be just two spaces between the longest item and its comment instead of the current four.
Additional context
The situation changes if the code itself needs to be formatted or if inline comments are so long that they violate the max line length. Neither of these are true in our case and, in my opinion, the formatted code is clearly worse than the original.