3

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?

Grodriguez
  • 21,501
  • 10
  • 63
  • 107
SEB
  • 89
  • 1
  • 6
  • 1
    If you insist on using the formatter of black, I think you should try to fix the problem of black instead of trying to use the yapf to simulate it. – Steven-MSFT Oct 22 '21 at 07:53
  • I tried and couldn't. Spent days and gave up. Asked on forums everywhere no one knew. I dont think anyone would help if I asked for help fixing black on this website. It's WSL and whole lot of specific explaining. Figured someone could just tell me "change this to this" or "black does this like this so format YAPF like this". Or even better maybe someones done it before and I can just download a configuration file. – SEB Oct 22 '21 at 21:09

1 Answers1

1

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.

Grodriguez
  • 21,501
  • 10
  • 63
  • 107