--- id: add-trailing-comma version: "4.0.0" license: MIT license_treatment: permissive maintenance: active --- # add-trailing-comma — Automatically add trailing commas to calls and literals License: permissive · Maintenance: active · Downloads: 88.4K/mo ## What it is and what it does add-trailing-comma is a code formatter that enforces a specific multi-line formatting style by automatically adding trailing commas to the last parameter or element in function calls, literals, definitions, imports, class declarations, and other multi-line constructs. It works as a standalone tool or integrates as a pre-commit hook to run on every commit. The tool targets a style where trailing commas improve readability and minimize git diffs when parameters are added or removed—each change affects only the lines being modified, preserving blame history. It handles function calls, tuple/list/dict/set literals, function and async function definitions, from-imports, class definitions, with statements, match statements, and PEP-695 type aliases. It also reformats hanging parentheses and braces to match indentation conventions. Use it for: - Enforce consistent multi-line formatting across a Python project via pre-commit hooks. - Automatically reformat function calls and literals to add trailing commas for cleaner diffs. - Standardize function and class definitions to include trailing commas on the last parameter. - Unhug misaligned parentheses and braces to match project indentation style. - Maintain code style compliance in CI/CD pipelines without manual review. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Automatically adds trailing commas to multi-line Python function calls, literals, definitions, imports, and class/type declarations, and can be run as a pre-commit hook. Yes. Low install friction, active maintenance, no security issues, and permissive MIT license. Useful for teams that want to enforce a specific trailing-comma style automatically. Install if your project or team values consistent multi-line formatting and wants to reduce manual code review overhead; skip if your codebase already uses a different formatter (e.g., Black) that handles trailing commas differently. ## Install pip install add-trailing-comma uv add add-trailing-comma poetry add add-trailing-comma ## Installing add-trailing-comma Before you install: Low friction: pure Python wheel with a single runtime dependency (tokenize-rt). Active maintenance with recent release (2025-10-10) and no known vulnerabilities. License in practice: MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects. Quickstart: pip install add-trailing-comma Then add to .pre-commit-config.yaml: - repo: https://github.com/asottile/add-trailing-comma rev: v4.0.0 hooks: - id: add-trailing-comma Requires Python 3.10 or later. Verify before relying: - Whether the tool modifies files in-place or outputs to stdout by default. - How the tool handles existing trailing commas in single-line constructs. - Performance characteristics on large codebases or deeply nested structures. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 88.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags trailing comma formatter, python code formatter, pre-commit hook, automatic code formatting, python style enforcement, code-formatter, pre-commit, style-enforcement [View on SkillFed](https://skillfed.io/packages/add-trailing-comma) · [View on PyPI](https://pypi.org/project/add-trailing-comma/)