darker icon indicating copy to clipboard operation
darker copied to clipboard

Support `ruff format` as a formatter

Open clintonsteiner opened this issue 2 years ago • 9 comments

Any plans to begin using ruff format instead of black for code formatting? Ruff is designed to be a drop in replacement for black and should provide a nice performance boost


@akaihola:

Some pointers to get started with implementation:

  • many-formatters sub-project
  • #251
  • #304
  • #51
  • #309
  • #266

clintonsteiner avatar Oct 26 '23 16:10 clintonsteiner

ruff is a very nice linter, I use it in all my new projects now, but it's not a replacement for black, which is a code reformatter. Yes to include ruff as a supported lint tool in darker, but not as a replacement for black!

mrfroggg avatar Dec 08 '23 16:12 mrfroggg

Thanks for the response! I should have been more clear, semi-recently they added formatting to it. Supposedly its 30x faster than black and a drop in replacement for 99.99% of scenarios

clintonsteiner avatar Dec 08 '23 17:12 clintonsteiner

Oh right, I only used linters in ruff so far! https://docs.astral.sh/ruff/formatter/ Nice to know!

mrfroggg avatar Dec 08 '23 18:12 mrfroggg

@clintonsteiner I'll definitely be looking into this. I love ruff's performance!

akaihola avatar Feb 23 '24 10:02 akaihola

Would using ruff be a replacement or an optional setting?

Svenito avatar Mar 05 '24 21:03 Svenito

@akaihola up to you but I'd probably do as an optional replacement for an iteration via setting an env variable (if you want it always on) or command line arg.

Would you mind assisting me with a little layout of the 3 files you'd start with when making this change as well as any other development tips?

clintonsteiner avatar Mar 07 '24 03:03 clintonsteiner

@clintonsteiner could you catch up on the discussion in #251? Also the following items are related or contain relevant discussion: #304, #51, #309, #266.

Also FYI @guettli @Carreau @jedie: the idea of alternative reformatters is popping up again. I love it.

akaihola avatar Mar 07 '24 07:03 akaihola

I would suggest being able to specify the formatter. We wouldn't be using Ruff (for various reasons) and being able to use darker with multiple formatters (even just the two) would make more sense. I see this is already suggested in #304. Happy to help out on this if need be.

Svenito avatar Mar 07 '24 09:03 Svenito

I've run ruff using darker --revision origin/main . -L "ruff check --line-length=88 --select E501,ANN" which allows for incremental addition of lint rules.

Will-Ruddick avatar Jul 04 '24 17:07 Will-Ruddick