Closed
Description
See also: many-formatters sub-project
Currently there's no way to run Darker and have it just do, say, isort
and flynt
but not reformat code using Black.
Also, there are open requests for replacing Black with another formatter or expanding the choices of formatters/linters:
- DRAFT: Apply pyupgrade. #51
- Support for
blue
as a formatter #251 / Add Blue as an alternative reformatter #309 - No support for using
flynt
to convert old string literal formatting to f-strings #266 - Support
ruff format
as a formatter #521
We could expand Darker's behavior in stages:
- extend configuration parameters:
- add
--black
/--no-black
; see - OR: add
--format=black
/--format=blue
/--format=ruff
/--format=none
- add
- add support for
blue
,Ruff
and other formatters; see - add another console entry point which defaults to
--format=none
(what would be a good name for that?) - change default for
darker
to--format=none
in version 2.0.0
For the option name, I've considered --format
, --formatter
, --reformat
and --reformatter
:
- Black calls itself a "formatter", so I discarded
--reformat
and--reformatter
(also for needless verbosity) - Linters are chosen with
--lint
, not--linter
, so for consistency, I'd prefer--format
over--formatter
At some point after making --format=none
the default, black
should be removed as a hard dependency. I can see two alternatives:
pip install 'darker[black]'
anddarker --black
for the current behavior- split into two Python packages:
- move all code from
darker
to a new package (package name to be decided) which- doesn't require
black
- doesn't run
black
by default (so has--format=none
as the default)
- doesn't require
- make
darker
depend on the new package andblack
- in
darker
, wrap and command line parser of the new package and override--format
by setting--format=black
as default
- move all code from
For the --black
/--no-black
/--blue
/--no-blue
design choice, some pros and cons are:
- 🟢👍
--black
: can enable multiple formatters (although what about the running order?) - 🟢👍
--black
: consistent with--isort
and--flynt
- 🟢👍
--black
: shorter to type
and for --format={black|blue|none}
:
- 🟢👍
--format=
: consistent with--lint=
- 🔴👎
--format=
inconsistent with--lint=
since--format=black
or--format=blue
don't really specify a command line - 🔴👎
--format=
: more verbose
Metadata
Metadata
Assignees
Projects
Status
Done