def METHOD_NAME(text: str, is_pyi=False) -> str:
    """Apply black and isort formatting to text."""
    from black import FileMode, format_str
    from isort.api import sort_code_string
    text = sort_code_string(text, profile="black", float_to_top=True)
    text = format_str(text, mode=FileMode(line_length=79, is_pyi=is_pyi))
    return text.replace("NoneType", "None")