I know very few about Black
so I did a quick investigation. The biggest difference is that yapf
may have non-deterministic results in the same code; while Black
guarantees the deterministic results.
In addition, although Black
has much fewer options than yapf
, looks like we can still customize the column width (Black
sets the default to 88).
In summary, Black
seems more suitable to play this role.
Reference:
- https://medium.com/3yourmind/auto-formatters-for-python-8925065f9505
- https://www.artemisconsultinginc.com/blog/What-Is-The-Benefit-Of-A-Code-Formatter#:~:text=After%20eliminating%20AutoPEP8%20from%20our,it%20would%20give%20inconsistent%20results.&text=Black%20was%20the%20clear%20winner,in%20reformatting%20the%20entire%20file.