pyzx icon indicating copy to clipboard operation
pyzx copied to clipboard

Setup formatter

Open EarlMilktea opened this issue 1 year ago • 5 comments

Resolves #232 .

EarlMilktea avatar Jun 10 '24 16:06 EarlMilktea

MEMO: This config. is optional (defaults to 88)

line-length = 120

EarlMilktea avatar Jun 10 '24 17:06 EarlMilktea

Resolves #232 .

Resolves #122.

dlyongemallo avatar Jun 19 '24 12:06 dlyongemallo

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 avatar Jun 19 '24 14:06 akissinger

@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?

EarlMilktea avatar Jun 19 '24 19:06 EarlMilktea

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).

dlyongemallo avatar Jun 25 '24 07:06 dlyongemallo

@EarlMilktea Why was this closed? I'd like to see something like this implemented.

dlyongemallo avatar Jul 12 '24 09:07 dlyongemallo