SEB
SEB

Reputation: 109

How to configure YAPF to format the same way as Black

Black won't work on my computer but I want YAPF to function the same way black does. Is there a way to change the custom settings of YAPF to format the exact same way as black? I figure black is industry standard and want to follow that. What settings should I change? Are there any repositories I can just copy?

Upvotes: 3

Views: 2627

Answers (1)

Grodriguez
Grodriguez

Reputation: 21995

I don't think you can get yapf to behave exactly like black, however the following would be a good start:

  • Select the built-in 'facebook' style
  • Set line-length to 88 characters (like black does)

i.e.:

yapf --style='{based_on_style: facebook, column_limit: 88}' somefile.py

With this you already get similar results to what black would do with the --skip-string-normalization option. It might be possible to get even closer by tweaking some knobs.

Upvotes: 2

Related Questions