Darker (version 3.0.0) is a Python utility that applies code formatting (using tools like Black, Ruff, isort, Flynt, and pyupgrade) only to regions of Python files that have changed since the last Git commit. This allows for gradual style unification in existing projects without large, disruptive formatting commits. It is actively maintained with regular releases.
pip install darkerNo compatibility data collected yet for this library.
To use Darker, navigate to your Git repository and run it on specific files or directories. This example demonstrates basic usage for formatting modified lines in a Python file and showing a diff. Ensure you have `darker` and its desired formatters (e.g., `black`) installed.
Move `skip_string_normalization` and `skip_magic_trailing_comma` from `[tool.darker]` to `[tool.black]` in your `pyproject.toml`.
Migrate baseline linting workflows to use the `Graylint` package instead of `darker --lint`.
Install Darker with the `black` extra: `pip install 'darker[black]'` or install Black separately: `pip install black`.
Pin `darker` and its integrated formatters/linters to compatible versions using `~=` in your `requirements.txt` or `pyproject.toml` and review Darker's release notes for known incompatibilities.
For pre-commit, try `--revision :PRE-COMMIT:` in your hook configuration. Ensure your CI/CD environment correctly sets `PRE_COMMIT_FROM_REF` and `PRE_COMMIT_TO_REF` if relying on Darker's default behavior within a pre-commit context.
Ensure Darker is installed (`pip install darker`) and your virtual environment is activated, or use `python -m darker` to invoke it directly.
If you want Darker to apply the formatting, remove the `--check` or `--diff` flag. If you want to accept the current state, commit your code and then run `darker` again to confirm no new changes are detected.
Install Black as an extra for Darker: `pip install 'darker[black]'`, or install Black separately: `pip install black`.
Move `skip_string_normalization` (and `skip_magic_trailing_comma` if used) from the `[tool.darker]` section to the `[tool.black]` section in your `pyproject.toml`.
Verify the file or directory path provided to Darker. Ensure there are no typos and the path is correct relative to where you are running the command.