Black Is the Way

Mando says “format your code”

Andrew Scott
The Startup

--

Recently it dawned on my team that we were wasting too much time during code reviews because of formatting inconsistencies between new PRs and the rest of our codebase. Owning mostly JVM services and libraries, we decided to use IntelliJ IDEA’s Code Style editor to create code formats that the whole team could agree on — for Java, Groovy, and Kotlin. Of course, during the decision-making process, differing opinions came up around the most minute of details, such as line wrapping in various scenarios, indentation levels, etc — however, we persevered, applied the formatting to all our code, shared the format with our contributors, and called it a job well done.

However, while this exercise ended up with our team spending less time on syntax nitpicks going forward, we still spent a fair amount of time creating a code style guide and distributing it — but even with that, there were some issues.

  1. The style choices were made by a team, and teams (and their opinions) change over time.
  2. We picked a specific vendor tool (IntelliJ IDEA), which, while a great tool, made our style guide more work for developers using different tools to use.

Luckily, when it comes to python, all of these problems have already been solved by Black.

Introducing Black

--

--

Andrew Scott
The Startup

Maintainer @OchronaSec | PANW, ex Expanse, ex Tenable | Security & Automation | All views are my own... and awesome