def _getArgSpec(func):
    """
    Normalize inspect.ArgSpec across python versions
    and convert mutable attributes to immutable types.

    :param Callable func: A function.
    :return: The function's ArgSpec.
    :rtype: ArgSpec
    """
    spec = getArgsSpec(func)
    return ArgSpec(
        args=tuple(spec.args),
        varargs=spec.varargs,
        varkw=spec.varkw if six.PY3 else spec.keywords,
        defaults=spec.defaults if spec.defaults else (),
        kwonlyargs=tuple(spec.kwonlyargs) if six.PY3 else (),
        kwonlydefaults=(
            tuple(spec.kwonlydefaults.items())
            if spec.kwonlydefaults else ()
        ) if six.PY3 else (),
        annotations=tuple(spec.annotations.items()) if six.PY3 else (),
    )
Normalize inspect.ArgSpec across python versions
    and convert mutable attributes to immutable types.

    :param Callable func: A function.
    :return: The function's ArgSpec.
    :rtype: ArgSpec