You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am trying to use black as a library and so far so good. It is easy to just call black.format_str(code_block, mode=Mode()) but I would like to pass a configuration as an argument as well. Is there any way I can create Mode object from a pyproject.toml file? Preferably I would like not to parse the file myself and create Mode object manually. So far I could find anything related to such thing inside the source code.
TLDR: I would like to call black.format_str in a way that it uses a pyproject.toml configuration specified by myself.
The text was updated successfully, but these errors were encountered:
After digging more I found the parse_pyproject_toml function inside black which returns a dictionary but this will just return a dictionary with all key-values under [tool.black] section. I would still need to filter that dictionary for keys/values that Node constructor accepts but I guess it is feasible. Maybe there are some other better alternatives?
BTW. black has a great documentation for its CLI api but I could not find much when it comes to library API. I only found the Contributing section. Is there something else?
We don't currently have a documented API; #779 is tracking that. Closing as you've solved your immediate problem and #779 tracks the bigger enhancement request.
Hello,
I am trying to use
black
as a library and so far so good. It is easy to just callblack.format_str(code_block, mode=Mode())
but I would like to pass a configuration as an argument as well. Is there any way I can createMode
object from apyproject.toml
file? Preferably I would like not to parse the file myself and createMode
object manually. So far I could find anything related to such thing inside the source code.TLDR: I would like to call
black.format_str
in a way that it uses apyproject.toml
configuration specified by myself.The text was updated successfully, but these errors were encountered: