skillfed

flake8-commas

Flake8 lint for trailing commas.

flake8-commas v4.0.0 310.4K downloads/30d#7,746 on PyPI134
Permissive license AGING released

What it is and what it does

flake8-commas is a linter plugin that checks trailing comma placement in Python code. It integrates directly into flake8 and runs as part of your normal linting workflow, reporting errors (C812–C819) when commas are missing or incorrectly placed in multi-line structures. The plugin is designed to enforce consistent comma style across dictionaries, lists, function arguments, and tuples, which reduces merge conflicts when multiple developers edit the same data structures.

The plugin supports multiple Python versions with version-specific rules: different comma requirements apply to Python 2, Python 3, Python 3.5+, and Python 3.6+. It handles edge cases like bare tuples, lambda parameters, subscripts with slices, and function definitions with unpacking. The package is permissive (MIT license) and has low installation friction—it's a pure Python wheel with only flake8 as a dependency.

Use it for:

  • Enforce trailing commas in team codebases to reduce merge conflicts when multiple developers modify adjacent lines in lists or dicts.
  • Catch accidental trailing commas that turn expressions into tuples (e.g., json_data = json.dumps({...}), becomes a tuple instead of the result).
  • Lint Python 3.5+ and 3.6+ codebases with version-specific comma rules by configuring which error codes to enforce.
  • Integrate comma style checking into CI/CD pipelines as part of flake8 without adding a separate tool.
  • Prevent bare tuple syntax errors and lambda parameter comma mistakes during code review.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A flake8 plugin that enforces trailing comma placement in Python code to reduce merge conflicts in multi-line dictionaries, lists, and function calls.

Yes, if you use flake8 and want to enforce trailing comma consistency to reduce merge conflicts. The plugin is lightweight, permissive, and integrates seamlessly. However, note that maintenance is aging (last release 820 days ago); if you need active support or compatibility with very recent Python/flake8 versions, consider black or add-trailing-comma as alternatives.

Install

flake8-commas on PyPI

pip

pip install flake8-commas

uv

uv add flake8-commas

poetry

poetry add flake8-commas

Installing flake8-commas

Before you install

Low friction: pure Python wheel with only flake8 as a runtime dependency. Maintenance status is aging—last release was 820 days ago—but the repository remains active and the project was recently revived after a naming transition in version 4.0.0 (2024-05-16).

License in practice

Permissive license (MIT) means you can use this freely in commercial and private projects without restriction or attribution requirement.

Quickstart

pip install flake8-commas

# Then run flake8 normally; the plugin activates automatically
flake8 your_file.py

# Errors like C812 (missing trailing comma) will appear in output

Requires flake8 to be installed and Python 3.8 or later.

Verify before relying

  • Whether the aging maintenance status (820 days since last release) affects compatibility with very recent Python or flake8 versions.
  • How this plugin's comma rules interact with or differ from black or add-trailing-comma when used together.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — flake8
Maintenance aging — 820 days since the last release
Last repo commit
First released
Downloads 310,448/month — #7,746 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: flake8_commas-4.0.0-py3-none-any.whl

Environment :: ConsoleFramework :: Flake8Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance

Tags

flake8 trailing comma enforcementpython comma lintingmerge conflict prevention code styleflake8 extension comma rulestrailing comma checkerpython dictionary list formattingcode style comma placement
lintingcode-stylemerge-conflict-prevention

More Python Modules packages