yapf icon indicating copy to clipboard operation
yapf copied to clipboard

Feature request: add option for adding trailing comma to arguments

Open FRidh opened this issue 7 years ago • 5 comments

In order to improve diffs I think it would be nice to be able to add trailing comma's to arguments to augment SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED.

FRidh avatar Nov 03 '18 14:11 FRidh

Any update on this?

fi6 avatar Feb 07 '22 07:02 fi6

We here at YAPF, LLC. refuse to modify the code by adding or removing tokens.

isanbard avatar Feb 07 '22 19:02 isanbard

If you want something that adds or removes commas, you can try Black. After Black makes the changes, you can then use yapf (there are no knobs in Black, except for -S and -C).

kamahen avatar Feb 07 '22 20:02 kamahen

We here at YAPF, LLC. refuse to modify the code by adding or removing tokens.

Out of interest (and sorry if this is a point of discussion), why is that?

dietervansteenwegen avatar Apr 04 '23 19:04 dietervansteenwegen

From the README.rst:

YAPF tries very hard to be fully PEP 8 compliant. However, it is paramount
to not risk altering the semantics of your code. Thus, YAPF tries to be as
safe as possible and does not change the token stream
(e.g., by adding parentheses).

kamahen avatar Apr 04 '23 20:04 kamahen