add-trailing-comma

4.0.0 · active · verified Fri Apr 17

add-trailing-comma is a Python utility that automatically adds trailing commas to function calls and literal structures (like lists, tuples, dictionaries, sets) to improve diff clarity and make future additions easier. It is currently at version 4.0.0 and is actively maintained, with releases often tied to Python version updates.

Common errors

Warnings

Install

Imports

Quickstart

First, create a Python file with some function calls or literals. Then, run `add-trailing-comma` on that file from your terminal. The tool will modify the file in-place, adding trailing commas where applicable.

# Create a Python file, e.g., 'example.py'
# -- example.py BEFORE --
# def my_function(arg1, arg2):
#     pass
# 
# my_list = [
#     1,
#     2
# ]
# 
# my_dict = {
#     'key1': 'value1',
#     'key2': 'value2'
# }

# Run the tool from your terminal:
# $ add-trailing-comma example.py

# -- example.py AFTER --
# def my_function(arg1, arg2,):
#     pass
# 
# my_list = [
#     1,
#     2,
# ]
# 
# my_dict = {
#     'key1': 'value1',
#     'key2': 'value2',
# }

view raw JSON →