Setup formatter
Resolves #232 .
MEMO: This config. is optional (defaults to 88)
line-length = 120
Resolves #232 .
Resolves #122.
I'm not sure about this, mainly just because I've never used auto-formatting at this level before.
It looks like this could potentially spam the commit logs by creating a double commit for almost everything. One is the actual commit, then a second commit e.g. putting a bit less/more whitespace somewhere because someone's editor isn't configured in the same way as ruff. Is consistent formatting worth the extra commit spam and/or effort? (genuine question, not a rhetorical one)
@akissinger (CC: @jvdwetering )
Let me first note that formatter CI does NOT run each time you commit: only once per merged PR because it's tracking master branch only.
Actually I admit Ruff (or black similarly) is sometimes too strict, but at the same time, it helps me a lot because...
- Contributors don't have to care about the coding style or consult coding style document
- Reviewer-friendly as diffs. are minimized, also easy to grep
- Reviewers don't have to manually check that the codes are PEP8-compliant
- Can detect unconventional styles: for example
if x: break
- Simplifies linter/editor configuration since we don't have to manually inspect which rules are associated with PEP8
If you're not happy with automatic commit, I'm willing to rewrite the CI to just report problems and urge contributors to fix. Which do you prefer?
Is consistent formatting worth the extra commit spam and/or effort? (genuine question, not a rhetorical one)
In a large code base touched by many people, a consistent style make certain tasks easier or more pleasant. Reading unfamiliar code in which the style switches between code blocks imposes an unnecessary cognitive load because the reader has to think about whether apparent differences are meaningful.
Extra commits can probably be reduced by documenting the expected style in the contributor guidelines and encouraging contributors to use automatic formatting tools (e.g., format on save in their editor).
@EarlMilktea Why was this closed? I'd like to see something like this implemented.