badge

Black formatter example

# Before Black formatting:
# fmt: off
def badly_wrriten_function ( some_arg  ) :
    long_list=["item one", "item two", [ "item one in nested list", "item two in nested list"]]
    if some_arg in long_list and ( some_arg  ) in long_list[ - 1 ] and some_arg is long_list[ - 1 , 0]:
                print("Now I'll print something really long","and I'll just keep printing to make the point") # with a comment just for show

    return None
# fmt: on

# After Black formatting:
def badly_wrriten_function(some_arg):
    long_list = [
        "item one",
        "item two",
        ["item one in nested list", "item two in nested list"],
    ]
    if (
        some_arg in long_list
        and (some_arg) in long_list[-1]
        and some_arg is long_list[-1, 0]
    ):
        print(
            "Now I'll print something really long",
            "and I'll just keep printing to make the point",
        )  # with a comment just for show

    return None

N.B. Black won’t work if you have indentation errors.