asottile / add-trailing-comma

A tool (and pre-commit hook) to automatically add trailing commas to calls and literals.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question]: How to avoid adding a comma in a single line ?

diegovalenzuelaiturra opened this issue · comments

Hi!

I've started using this tool, and the following is happening

ValueError("something ...",)

I'm not sure if that's desired, but I'd like to avoid adding trailing comma here. ( It also happens in prints statements with a single string) - Currently flake8-commas1 mark them as trailing comma prohibited (C819).

Is there a way to avoid adding trailing comma in specific lines ?

Thanks!

Footnotes

  1. https://github.com/PyCQA/flake8-commas/

watch this and then try again: https://youtu.be/ritp4gAqNMI

add-trailing-comma actually removes that comma: https://github.com/asottile/add-trailing-comma#remove-unnecessary-commas

I've added a simple reproducible example at least from the print statement:

$ cat print_test.py

print(
    'This is a really long string, to be used as an example for https://github.com/asottile/add-trailing-comma/issues/157.'
)

add-trailing-comma version: 2.4.0

$ add-trailing-comma print_test.py
WARNING: add-trailing-comma will only use 3.6+ mod after 3.0
Rewriting print_test.py

$ cat print_test.py

print(
    'This is a really long string, to be used as an example for https://github.com/asottile/add-trailing-comma/issues/157.',
)

title says "in a single line"