from typing import Iterable


def check_wires(wires):
    """Checks that ``wires`` is either a non-negative integer or a list of non-negative integers.

    If ``wires`` is an integer, wrap it by a list.

    Args:
        wires (int or list[int]): (subset of) wires of a quantum node

    Return:
        list: list of wire indices

    Raises:
        ValueError: if the wires argument is invalid
    """
    if isinstance(wires, int):
        wires = [wires]

    msg = "wires must be a positive integer or a " "list of positive integers; got {}.".format(
        wires
    )
    if not isinstance(wires, Iterable):
        raise ValueError(msg)
    if not all([isinstance(w, int) for w in wires]):
        raise ValueError(msg)
    if any([w < 0 for w in wires]):
        raise ValueError(msg)
    return wires