skillfed

darker

Apply Black formatting only in regions changed since last commit

darker v3.0.0 219.7K downloads/30d#9,321 on PyPI685
Permissive license BSD AGING released

What it is and what it does

Darker is a Git-aware Python code formatter that applies reformatting selectively to only the lines you've changed since a prior commit or revision. It sits between your version control system and formatters like Black or Ruff, solving the problem of introducing formatting-only commits that clutter history and blame attribution. Instead of reformatting an entire codebase in one giant commit, you can reformat incrementally as you touch code for other reasons—useful when adopting a new style in an existing project or contributing to upstream codebases you don't fully control.

The package wraps multiple formatting tools (Black, Ruff formatter, isort for imports, flynt for f-string conversion, and pyupgrade for syntax upgrades) and applies them only to Git-detected changes. It compares the working tree against a baseline revision, identifies which lines have been modified, and reformats only those regions. As of version 3.0.0, Black is no longer bundled by default; you install formatters as optional dependencies. The tool runs as a command-line utility or Python module and integrates with pre-commit hooks and pytest plugins.

Use it for:

  • Gradually adopt Black or Ruff formatting in an existing codebase without a single massive reformatting commit.
  • Contribute to upstream projects with different style standards by formatting only your own changes.
  • Combine import sorting (isort) and f-string conversion (flynt) with selective code formatting on modified lines.
  • Integrate formatting into CI/CD to enforce style only on new or changed code, not the entire repository.
  • Use as a pre-commit hook to automatically format only the lines you've edited before committing.

Worth the install?

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

Darker reformats Python source code in Git repositories, but only applies changes to regions that have been modified since a specified revision, using Black, Ruff, isort, flynt, or pyupgrade as the underlying formatter.

Yes, if you need selective code formatting in a Git workflow. The low install friction, permissive license, and stable maintenance make it a practical choice for teams adopting formatters incrementally. Skip it if you prefer whole-codebase reformatting or are starting a project from scratch—use Black or Ruff directly instead. The 347-day gap since last release is not a red flag given the repository's continued activity and clear scope, but verify that the aging status doesn't signal reduced support for your specific use case.

Install

darker on PyPI

pip

pip install darker

uv

uv add darker

poetry

poetry add darker

Installing darker

Before you install

Low friction install with three lightweight runtime dependencies (darkgraylib, toml, typing_extensions). The package is aging—last release was 347 days ago—but the repository remains active and well-starred (685 stars), suggesting stable maintenance rather than abandonment.

License in practice

BSD permissive license places no restrictions on use, modification, or distribution in commercial or proprietary projects.

Quickstart

pip install darker

# In a Git repository with modified Python files:
darkr our_file.py

# Or with a specific formatter:
python -m darker --formatter=ruff our_file.py

Requires a Git repository; Black is no longer installed by default as of version 3.0.0, so you must install an optional formatter (black, ruff, pyupgrade, or none) separately if you want code reformatting beyond import sorting or string conversion.

Verify before relying

  • Whether the aging maintenance status (347 days since last release) signals reduced development or stable maturity for this use case.
  • Performance characteristics when run on large codebases with many modified regions.

Package facts

License BSD (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 3 — darkgraylib, toml, typing_extensions
Maintenance aging — 347 days since the last release
Last repo commit
First released
Downloads 219,666/month — #9,321 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: darker-3.0.0-py3-none-any.whl

Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.9

Tags

partial code formatting gitreformat only changed linesblack on modified codeselective python formattinggit-aware code reformatterformat changed regions onlyincremental code style
git-awareincremental-formattingcode-quality

More Quality Assurance packages