def METHOD_NAME(
    name: str,
    source: str,
    *,
    return_type: Any = MISSING,
    globals: Dict[str, Any] = None,
    locals: Dict[str, Any] = None,
) -> Callable:
    """Generate function from Python from source code string."""
    assert locals is not None
    if return_type is not MISSING:
        locals["_return_type"] = return_type
    exec(source, globals, locals)  # nosec: B102
    obj = locals[name]
    obj.__sourcecode__ = source
    return cast(Callable, obj)