Black

Black, the Python formatter.

Formats
Python
In ur.toml
[format.python] style = "black"
Its options
https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html

Formatted

cart.py, as written
# What a cart costs.
def subtotal(items,tax = 0.2):
    return sum( item.price*item.quantity for item in items )*(1+tax)
def label(item): return item.name+' x'+str(item.quantity)
ur format --style black cart.py
# What a cart costs.
def subtotal(items, tax=0.2):
    return sum(item.price * item.quantity for item in items) * (1 + tax)


def label(item):
    return item.name + " x" + str(item.quantity)

Try it in the playground →

Defaults

The shared options, as Black sets them when nothing configures it. Its own names for them are read from its configuration files, but ur.toml sets them by the shared name only.

OptionDefaultBlack calls it
width88line-length
indent.width4
indent.style
line-ending"auto"
trailing-comma.add"multiline"
trailing-comma.forces-breaktrueskip-magic-trailing-comma
quotes"double"skip-string-normalization
targettarget-version

Its own options

Set in a table named for it, such as [format.black], or in a language's table, as black = { ... }.

OptionDefaultWhat it does
pyifalseFormat every file as a typing stub, as .pyi files are formatted. Takes true or false.
ipynbfalseFormat every file as a Jupyter notebook. Takes true or false.
python-cell-magics[]Notebook cell magics, such as %%time, whose cells are formatted as Python. Takes a list of strings.
skip-source-first-linefalseLeave each file's first line as written, for a first line that is not Python. Takes true or false.
previewfalseFormat in Black's preview style, the changes planned for its next stable style. Takes true or false.
unstablefalseFormat in the preview style with its unstable features as well. Takes true or false.
required-versionThe Black version the project requires, which Black checks before it formats. Takes any value.
enable-unstable-feature[]Unstable preview features to turn on one at a time. Takes a list of "string_processing", "hug_parens_with_braces_and_square_brackets", "wrap_comprehension_in", "simplify_power_operator_hugging", "wrap_long_dict_values_in_parens", "fix_if_guard_explosion_in_case_statement", "pyi_overload_group_blank_lines", "pyi_blank_line_before_decorated_class".