compas icon indicating copy to clipboard operation
compas copied to clipboard

Suggestion: switch to black code formatter

Open gonzalocasas opened this issue 2 years ago • 2 comments

Considering the prominence of black (https://github.com/psf/black) as the increasingly de-facto standard for code formatting on Python, it might be a good idea to switch to it and give up all hand-crafted control of code style in favor of total consistency.

Reasons to use black:

  • Our code is mostly black compatible already. I tried locally, and by far, the largest change is the consistent update of all string quotes to be double quoted.
  • Consistency, consistency, consistency. More and more big (and small) projects use it, and the lack of configurability means all projects are styled consistency even across organizations.
  • When working with code, you don't even have think about formatting, it will be done entirely for you. If you're an experienced coder, this is good because you can focus on what matters, if you are a novice coder, it's also good because it removes a whole category of review comments that need to be addressed later on.
  • It's not configurable: you can have any color you want, as long as it's black.
  • It's called black!

Reasons not to use black:

gonzalocasas avatar Mar 05 '22 21:03 gonzalocasas

sure but perhaps this can be part of COMPAS 2.0?

tomvanmele avatar Mar 06 '22 08:03 tomvanmele

👍

gonzalocasas avatar Mar 06 '22 08:03 gonzalocasas

OCD ;)

😂

@gonzalocasas this in integrated in the CI. see #1208 for the suggesion of invoke black as per pre-commit

jf--- avatar Apr 08 '24 18:04 jf---

black is already integrated, and we have https://github.com/compas-dev/compas/issues/1329 for the pre-commit hook

gonzalocasas avatar Apr 23 '24 08:04 gonzalocasas