Registry / testing / add-trailing-comma

add-trailing-comma

JSON →
library4.0.0pypypiunverified

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.

pip install add-trailing-comma
INSTALL
IMPORT
SIG · ADD-TRAILING-COMMA
A
add-trailing-comma
testingpythonv4.0.0
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

add-trailing-comma (CLI)
add-trailing-comma <filenames>...
import add_trailing_comma
This library is a command-line tool and is not intended for programmatic import or direct use as a Python module.

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', # }
add-trailing-comma --version
Debug
Known issues
breakingAs of version 4.0.0, the `add-trailing-comma` tool itself now requires Python 3.10 or newer to run. Attempting to install or execute it with older Python versions will result in an error.
fix
Ensure you are running `add-trailing-comma` within a Python 3.10+ environment. If you need to use an older Python environment, you must install an older version of `add-trailing-comma` (e.g., `<4.0.0`).
affects: 4.0.0+
breakingThe command-line flags `--py36-plus` and `--py310-plus` were removed in version 4.0.0. The tool now automatically infers the target Python version of the code it's formatting based on the Python environment it's running in.
fix
Remove these flags from your command-line invocations or pre-commit configurations. The tool will now handle the appropriate Python version inference.
affects: 4.0.0+
gotcha`add-trailing-comma` modifies files in-place without creating backups. It is strongly recommended to use this tool within a version-controlled repository (e.g., Git) to easily review and revert any unintended changes.
fix
Always commit your code before running `add-trailing-comma` or ensure you have a robust backup strategy. Integrate it as part of a pre-commit hook for automated version control management.
affects: All versions
gotchaWhen combining `add-trailing-comma` with other code formatters (e.g., Black, Ruff), it should generally be run *before* the other formatters in your pipeline (e.g., pre-commit hooks). Some opinionated formatters might remove trailing commas in certain contexts, potentially undoing `add-trailing-comma`'s work if run out of order.
fix
Configure your pre-commit hooks or formatting scripts to execute `add-trailing-comma` before other formatters that might conflict with trailing comma placement.
affects: All versions
Upgrade
Version history
4.0.0latest on PyPI · released Oct 10, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
47 hits · last 30 days
node
40
OpenAI (training)
1
Resources