falconry / falcon

The no-magic web data plane API and microservices framework for Python developers, with a focus on reliability, correctness, and performance at scale.
https://falcon.readthedocs.io/en/stable/
Apache License 2.0
9.53k stars 945 forks source link

Migrate to another code formatter? #2218

Closed vytas7 closed 7 months ago

vytas7 commented 8 months ago

While blue is awesome since it is better tuned for our needs out of the box, and I just :blue_heart: blue, it seems that it is stuck on flake8 v4.x, and it hasn't been updated in two years. @grantjenks @warsaw If you intend to carry on with blue, we'll likely try to keep it, but otherwise we might need to look for alternatives. "Back in Black", or maybe ruff?

warsaw commented 8 months ago

Personally, I've made the move to ruff which covers almost all of blue's functionality with the one notable exception, it's handling of right hanging comments. I don't intend to maintain blue, but instead help ruff along to full blue parity.

vytas7 commented 7 months ago

Alright, I see that @grantjenks has moved sortedcontainers to ruff as well, that sums it up I guess.

CaselIT commented 7 months ago

I usually use use black in other projects, but I have nothing against using ruff.

@vytas7 do you think it could make sense to try each and post here the commits so that we can look at what change they would introduce?

IIRC black can be configured to not convert ' to ", but that would mean that it would accept both ' and " for strings. Outside that not much changes should happen.

Don't know about what options ruff has, but I gather it's much more than just a code formatter, so it may have more config knobs to tune

vytas7 commented 7 months ago

Yeah, I'll try to create a prototype with ruff. ruff is alluring not just for its brute speed, but it also has the potential to replace all other tools/plugins that we use (import sorting, etc). I'll need to figure out the required config flags though.

Ideally it should introduce zero code changes against blue (with an optimal configuration) as the only difference Barry mentioned doesn't apply to Falcon I think, even if we had aligned comments before, we had lost them to black which we used before blue.

warsaw commented 7 months ago

You should be able to configure ruff to be compatible with black or blue, or anything in between. Like I mentioned earlier, the only thing lacking for me at the moment is right hanging comment line up, and there's an open ticket on that issue.