finds.dev

asottile/add-trailing-comma

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

View on GitHub

★ 373PythonMITupdated Jul 2026

// the take

A Python AST-aware formatter that adds trailing commas to multi-line calls, definitions, imports, and literals. Ships as a pre-commit hook. Does one thing and does it well — if you care about cleaner diffs when adding or removing arguments, this is exactly the tool.

Works at the token level, not just regex, so it handles edge cases like `*args`/`**kwargs` correctly (skips them). Plugin architecture per syntax construct keeps the code organized and makes it easy to see exactly what rules apply. Covers modern Python syntax including match statements and PEP-695 type parameters, so it won't lag behind the language. The 'unhug' reformatter that also fixes misaligned opening parens is a nice bonus that black doesn't do.

373 stars after what appears to be years of existence suggests the audience is niche — most teams just defer to black or ruff, which overlap somewhat. No integration with ruff's formatter means you may end up fighting between tools if you run both. The 'remove unnecessary commas' feature is a footgun if you're not paying attention — the tool named for adding commas also removes them under some conditions. Setup still uses setup.cfg/setup.py rather than pyproject.toml, which is a minor but dated smell.

We read the README, the directory tree and a key source file in July 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
373
Forks
28
Language
Python
License
MIT
Last commit
15 Jul 2026

// nearby

If add-trailing-comma isn't quite it.

All repos →