from typing import Callable
from typing import List
import inspect


def get_kwarg_names(function: Callable) -> List[str]:
    """Retrieve the names of the keyword arguments.
    Retrieve the names of the keyword arguments accepted by `function`
    as a list of strings.

    Parameters
    ----------
    function
        The function to retrieve keyword argument names from.

    Returns
    -------
    List[str]
        The accepted keyword arguments as a list of strings.

    """

    try:
        argspec = inspect.getfullargspec(function)
    except TypeError:
        return []

    if argspec.varargs:
        return argspec.kwonlyargs or []
    else:
        return argspec.args or []