import typing


def _normalize_sample_plan(sample, plan) -> typing.Tuple[list, list]:
    """Normalize samples and plans to list of samples and plans

    Parameters
    ----------
    sample :

        Sample metadata. If a beamtime object is linked, an integer will be interpreted as the index appears in
        the ``bt.list()`` method, corresponding metadata will be passed. A customized dict can also be passed as
        the sample metadata.

    plan :

        Scan plan. If a beamtime object is linked, an integer will be interpreted as the index appears in the
        ``bt.list()`` method, corresponding scan plan will be A generator or that yields ``Msg`` objects (or an
        iterable that returns such a generator) can also be passed.

    Returns
    -------
    sample :

        The list of samples

    plan :

        The list of plans
    """
    if isinstance(sample, list) and not isinstance(plan, list):
        plan = [plan] * len(sample)
    elif not isinstance(sample, list) and isinstance(plan, list):
        sample = [sample] * len(plan)
    elif not isinstance(sample, list) and not isinstance(plan, list):
        plan = [plan]
        sample = [sample]
    if len(sample) != len(plan):
        raise RuntimeError("Samples and Plans must be the same length")
    return sample, plan