Is it possible to call Black as an API?
You could try using format_str
:
from black import format_str, FileMode
res = format_str("some python code", mode=FileMode())
print(res)
Use black.format_file_contents
.
e.g.
import black
mode = black.FileMode()
fast = False
out = black.format_file_contents("some python code", fast, mode)
https://github.com/psf/black/blob/19.3b0/black.py#L642