Calmcode - black: functions

Format Python Functions with Black

1 2 3 4 5

Black can handle all sorts of Python code. Not just data containers, but functions and other callables too!

So if we start with this;

def open_up_this_here_file(filepath: os.PathLike, read_method: str = 'w', verbose: bool = True, debug: bool = False):
    """Does a whole bunch of things this one function does right here."""
    with open(filepath, read_method) as f:
        print(f.read())

We will end up with;

def open_up_this_here_file(
    filepath: os.PathLike,
    read_method: str = "w",
    verbose: bool = True,
    debug: bool = False,
):
    """Does a whole bunch of things this one function does right here."""
    with open(filepath, read_method) as f:
        print(f.read())