The title makes it sound like there may be several options, but I think black is the de facto.
So, why should we use black?
- Consistent code base
- Never have to worry about formatting ever again, and it looks good
- Effectively solves about 95% of flake8 errors for you. No more annoyance trying to figure out why flake8 is yelling at you.
- Consistent format => smaller diffs => smaller code reviews
Basically, people are allowed to write code however they want, and then before they commit, just run it through black (either manually or via a pre-commit git hook) and it will take care of any formatting for you.
As far as implementation, the recommended way is to just do one large commit that re-formats the entire codebase, and then use git-hyper-blame or
git blame --ignore-rev and co to ignore that commit and still be able to see who wrote what.
Also, if you got the time here’s a cool talk from the creator of black, Lukasz Langa (who also is a core python dev)