ietf-tools / www

A customized CMS for the IETF website
BSD 3-Clause "New" or "Revised" License
25 stars 45 forks source link

Setup linting #379

Open kesara opened 8 months ago

kesara commented 8 months ago

Set up linting with flake8 / black.

mgax commented 6 months ago

We have been using ruff at Torchbox lately, as a replacement for both flake8 and black (they recently added support for code formatting), with good results. It's much faster, has more configuration options, and replaces multiple tools with a single one. Is there a strong preference to use flake8 and black?

rjsparks commented 6 months ago

There is a preference for black, because it isn't configurable. I've not noticed black being slow - are the speed differences in replacing flake8? I have no qualms replacing flake8.

Does ruff undo some of the heavy-handed "there is only one way" formatting rules that are at the core of black's principles?

mgax commented 6 months ago

Does ruff undo some of the heavy-handed "there is only one way" formatting rules that are at the core of black's principles?

It does provide more options, but the defaults aim to be compatible with black:

Ruff’s formatter aims to be drop-in compatible with Black out-of-the-box — which means great defaults with zero configuration. But it does expose a few additional settings.

I'd argue there is no meaningful downside to using the ruff formatter with the default settings, perhaps with a comment in its configuration block to the effect of we stick to black's formatting rules, please don't tweak the settings, and a link to the styleguide (which, in turn, would document a preference for black-style formatting).