Skip to content

Commit f485af9

Browse files
authored
Merge pull request #829 from akaihola/readme-black-line-range
docs: update README to reflect Black's line-ranges support
2 parents 43b3287 + 7d72bd0 commit f485af9

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

README.rst

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,21 @@ you'd like to only change formatting when you're touching the code for other rea
9090
This can also be useful
9191
when contributing to upstream codebases that are not under your complete control.
9292

93-
Partial formatting is not supported by Black_ itself,
94-
for various good reasons, and so far there hasn't been a plan to implemented it either
95-
(`134`__, `142`__, `245`__, `370`__, `511`__, `830`__).
96-
However, in September 2021 Black developers started to hint towards adding this feature
97-
after all (`1352`__). This might at least simplify Darker's algorithm substantially.
93+
Partial formatting was not supported by Black_ itself when Darker was originally
94+
created, which is why Darker was developed to provide this functionality.
95+
However, Black has since added the `-\-line-ranges`_ command line option for partial
96+
formatting, which could potentially simplify Darker's implementation.
97+
98+
.. _-\-line-ranges: https://black.readthedocs.io/en/latest/usage_and_configuration/the_basics.html#line-ranges
9899

99100
The ``--range`` option in `the Ruff formatter`_
100-
does allow for partial formatting of a single range,
101+
allows for partial formatting of a single range as well,
101102
but to make use of it,
102103
Darker would need call `the Ruff formatter`_ once for each modified chunk.
103104

104-
__ https://github.com/psf/black/issues/134
105-
__ https://github.com/psf/black/issues/142
106-
__ https://github.com/psf/black/issues/245
107-
__ https://github.com/psf/black/issues/370
108-
__ https://github.com/psf/black/issues/511
109-
__ https://github.com/psf/black/issues/830
110-
__ https://github.com/psf/black/issues/1352
111-
112-
But for the time being, this is where ``darker`` enters the stage.
113-
This tool is for those who want to do partial formatting right now.
105+
However, Black doesn't help in determining which line ranges to format.
106+
This is where ``darker`` enters the stage.
107+
This tool is for those who want to do partial formatting for modified parts of the code.
114108

115109
Note that this tool is meant for special situations
116110
when dealing with existing code bases.
@@ -950,10 +944,10 @@ To sort imports when the ``--isort`` option was specified, Darker proceeds like
950944
Limitations and work-arounds
951945
=============================
952946

953-
Black doesn't support partial formatting natively,
954-
and `the Ruff formatter`_ only accepts a single line range.
955-
Because of this, Darker lets them reformat complete files.
956-
Darker then accepts or rejects chunks of contiguous lines touched by the formatter,
947+
Although Black has added support for partial formatting with the `--line-ranges` command
948+
line option, and `the Ruff formatter`_ accepts a single line range for ``--range``,
949+
Darker lets Black or Ruff reformat complete files.
950+
Darker then accepts or rejects chunks of contiguous lines touched by Black or Ruff,
957951
depending on whether any of the lines in a chunk were edited or added
958952
between the two revisions.
959953

0 commit comments

Comments
 (0)