Please manage commas
See original GitHub issueI expect yapf, as a style-normalizer, to handle the trailing comma issue for me. Some writers put it always, others never, and yapf should make the code look the same regardless of who wrote it.
a_very_long_function_name(
long_argument_name_1=1,
long_argument_name_2=2,
long_argument_name_3=3,
long_argument_name_4=4,
)
a_very_long_function_name(long_argument_name_1=1,
long_argument_name_2=2,
long_argument_name_3=3,
long_argument_name_4=4)
Desired output: (in all three cases)
a_very_long_function_name(
long_argument_name_1=1,
long_argument_name_2=2,
long_argument_name_3=3,
long_argument_name_4=4,
)
a_very_long_function_name(
long_argument_name_1=1,
long_argument_name_2=2,
long_argument_name_3=3,
long_argument_name_4=4,
)
Actual output: (note trailing comma missing in second case)
$ yapf --style facebook ./demo.py
a_very_long_function_name(
long_argument_name_1=1,
long_argument_name_2=2,
long_argument_name_3=3,
long_argument_name_4=4,
)
a_very_long_function_name(
long_argument_name_1=1,
long_argument_name_2=2,
long_argument_name_3=3,
long_argument_name_4=4
)
In this case I have to hunt down missing trailing commas and fix them by hand, which is very similar to the problem yapf was made to solve – often in code reviews you’ll see junior devs told “trailing commas are nice”.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:47
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Comma Rules for Clear Writing (with Examples) - HubSpot Blog
Use a comma between two coordinate adjectives that describe the same noun. Use a comma to highlight additional, non-essential information about ...
Read more >Should I use a comma before or after “please” in a sentence?
If please is at the beginning of a sentence, you can choose whether or not to put a comma after it. It depends...
Read more >In what cases should I use a comma after "please"?
A comma is almost always required before "please" at the end of the sentence. Whether to use a comma or not depends on...
Read more >A Word, Please: When to use commas, when not to use them
It's an example of a comma situation that confounds many people yet is surprisingly easy to handle. Did you notice that, in our...
Read more >Commas (Eight Basic Uses) - Indiana University East
Rule: Use a comma after an introductory clause or phrase. ... Please send the letter to Greg Carvin at 708 Spring Street, Washington,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
for those looking for a battle-tested tool which modifies the token stream to add commas (with options for different target python versions) I’ve written add-trailing-comma
In general, I’m against modifying the token stream. I did it before and it’s fraught with problems. If someone wants to submit a patch, I’ll consider it. But it’ll have to be contained behind a style knob and come with a bevy of tests…