Black's public API
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 41.8k
- Forks
- 2.9k
- Avg merge
- 5d 6h
- Merged PRs (30d)
- 9
Description
With previous versions, it was possible to just use black.format_str(string) or black.format_str(string, line_length=82).
Now one needs to do:
black.format_str(string, mode=black.FileMode(line_length=82))
It's not a big deal in a module, but format_str was also useful in notebooks to display examples of Python code programmatically generated (for example by astunparse.unparse(tree)).
Therefore, it could be nice to support also black.format_str(string) and black.format_str(string, line_length=82).
The line_length argument is useful when one wants to get code adapted for a presentation (made with Jupyter for example).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the public black.format_str API and inspect how it currently accepts FileMode, including the existing line_length handling. Confirm the desired calls work with and without an explicit line length, then run the relevant formatter API tests or add coverage for those calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100