GEMDAT
GEMDAT copied to clipboard
Consider dropping yapf for ruff formatter
Formatting is now built into ruff (https://astral.sh/blog/the-ruff-formatter) as part of 0.1.2.
It's about 100x faster than yapf. Although it is in preview, it's considered production ready.
Its very nice for new projects, not so much for existing ones: https://github.com/duqtools/duqtools/issues/669
The diff would be: 31 files changed, 555 insertions(+), 732 deletions(-)
I still want this 😅
Now that it is has come along a bit more, and I have used it in other repos, I also want to update GEMDAT to use ruff for formatting. I prefer the formatting style of ruff and it now has some configuration options if necessary (most importantly a toggle for single quotes)
It can replace yapf and nbqa (for linting notebooks) in the pre-commit config.
Any thoughts on this @SCiarella ?
I don't have a strong opinion on yapf vs ruff, so I totally trust you on this! Go with the one you like the most!
I don't like that it would rewrite most of the history. I hoped that at some point there would be feature parity between the two formatters, so no changes to the source code (except changing the formatter) would be necessary
I don't think it's so bad. There will not be feature parity between the two. The python community has largely adopted black as the goto formatting style and ruff mimicks that. Yapf is fairly dated at this point and not very actively developed anymore.
It hurts once, but in the long run it will pay off by maintaining history better. One of the issues with yapf is how it formats functions and dicts.
def optimal_n_paths(F_graph: nx.Graph,
*,
start: Collection,
stop: Collection,
method: _PATHFINDING_METHODS = 'dijkstra',
n_paths: int = 3,
min_diff: float = 0.15) -> list[Pathway]:
vs ruff/black:
def optimal_n_paths(
F_graph: nx.Graph,
*,
start: Collection,
stop: Collection,
method: _PATHFINDING_METHODS = 'dijkstra',
n_paths: int = 3,
min_diff: float = 0.15,
) -> list[Pathway]:
This is means that with yapf, changing the function name could incur 10 lines changed. Imo the 2nd is way nicer in the sense that ruff/black would give cleaner diffs. Most of the changes are of this kind.
Do it then :rocket: :face_with_peeking_eye:
#yolo