from importlib import import_module
from typing import Callable


def import_function(function_path: str) -> Callable:
    """
    Import a function from a dotted path.

    Example:

           >>> import_function("generate_changelog.pipeline.noop_func")
           <function noop_func at 0x11016d280>

    Args:
        function_path: A dotted path to a function

    Returns:
        The callable function
    """

    bits = function_path.split(".")
    function_name = bits[-1]
    module = import_module(".".join(bits[:-1]))
    return getattr(module, function_name)