Darker is a Python code formatting utility designed to improve code style incrementally. Instead of reformatting entire files, it concentrates on regions that have changed, helping developers avoid unrelated modifications in established codebases.
The program is particularly useful when introducing consistent formatting to an existing project. Developers can improve the style of new and modified code without producing extensive changes to untouched sections, making pull requests easier to review.
Darker integrates with Git to identify modifications between revisions, but it can also operate outside Git repositories. It combines formatting with optional import organisation and syntax modernisation, providing a flexible approach to maintaining Python source code.
This is free and open source software.
Key Features
- Reformats only modified regions of Python source files.
- Supports Black and Ruff as code formatting engines.
- Uses Git revisions to identify lines that have changed.
- Allows formatting changes to be compared against a specified commit or branch.
- Can also operate in ordinary directories outside Git repositories.
- Supports optional import sorting through isort.
- Integrates with flynt to modernise string formatting using f-strings.
- Supports Python syntax modernisation through pyupgrade.
- Provides check mode to identify files requiring formatting without modifying them.
- Offers diff output for examining proposed formatting changes.
- Supports syntax highlighting in terminal diff output.
- Checks that formatting preserves the effective abstract syntax tree.
- Reads configuration from pyproject.toml.
- Supports parallel processing through configurable worker counts.
- Integrates with pre-commit hooks, GitHub Actions and development environments.
- Cross-platform support – runs on Linux, macOS, and Windows.
Website: github.com/akaihola/darker
Support:
Developer: Antti Kaihola
License: BSD 3-Clause ‘New’ or ‘Revised’ License
Darker is written in Python. Learn Python with our recommended free books and free tutorials.
Related Software
| Python Code Formatters | |
|---|---|
| Ruff | Extremely fast Python linter and code formatter |
| YAPF | Python formatter based on clang-format |
| Black | Uncompromising Python code formatter |
| isort | Python utility and library to sort imports |
| autopep8 | Formats Python code to conform to the PEP 8 style guide |
| Darker | Apply black reformatting to Python files |
| Pyink | Python code formatter |
| docformatter | Automatically formats Python docstrings for consistent style |
| SSort | Sorts Python statements by dependency for clearer code |
| reorder-python-imports | Reorders Python imports into a consistent, readable layout |
| μsort | Sorts import statements |
| eradicate | Remove commented-out code from Python files |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.