Kattis / problemtools

Tools to manage problem packages using the Kattis problem package format.
MIT License
101 stars 70 forks source link

Use Black formatting #249

Open incaseoftrouble opened 7 months ago

incaseoftrouble commented 7 months ago

Hi,

This is more of a recommendation that would ease PR / Merging significantly: Namely, use / require the python formatter black. See here for its documentation.

Basically, black defines one very "rigid" code style, i.e. after formatting a file with black, it will almost always look the same, no matter what formatting one starts from. This may at first sound constricting, but if the style is so rigid, no formatting changes can accidentally creep into MRs and only "actual" changes appear in the PR.

Usage is quite simple. pip install black followed by black problemtools/ to format all .py files in that folder. So it also is rather simple to update all existing forks etc.

Tagl commented 7 months ago

An alternative is ruff

incaseoftrouble commented 7 months ago

Oh thanks, I didn't know that. I have no strong opinion on ruff over black, the main point of this issue is to suggest to use any of the reasonably popular formatters to have a defined formatting. This project is small enough that there probably isn't a noticeable difference between black and ruff, and its just about deciding whether it is a good idea (I really think so) and picking whichever seems more stable (both seem very mature).

incaseoftrouble commented 4 months ago

Bump on this: I "switched" most of my projects to ruff thanks to your suggestion @Tagl

For the sake of this issue: Note that ruff and black are the "same", in the sense that ruff does black formatting + a lot of other stuff. Using ruff is nice because it also does a lot of static analysis and quick fixes.

I can add ruff with a pre-commit hook / open a PR to see how the repo would look like with ruff applied.