from typing import Optional
from typing import List
from typing import Callable


def generate_fake_wait_while(*, status: str, status_info: Optional[List[str]] = None) -> Callable:
    """Generate a wait_while function that mutates a resource with the specified status info."""
    if status_info is None:
        status_info = []

    def _wait_while_status(**kwargs):
        # We need either a `module` or `execution` argument
        if "module" in kwargs:
            module = kwargs["module"]
            module.status = status
            module.status_info = status_info
            return module
        elif "execution" in kwargs:
            execution = kwargs["execution"]
            execution.status = status
            execution.status_info = status
            return execution

    return _wait_while_status