from typing import List
from typing import Any
from typing import Callable


def is_each_element(
    type_: type, input_: List[Any], transform: Callable[[Any], Any] = lambda x: x
) -> bool:
    """
    Check if each element in a list is of a given type.

    :param type_: Expected :code:`Type` of each element in the :code:`input_` which is a :code:`list`.
    :type type_: Type
    :param input_: A :code:`list`.
    :type input_: List[Any]
    :param transform: We may apply some transforms to
        each element before making these checks. This is to check if a certain key
        in a Dict matches the expected type. In case this is not needed,
        leave the argument unset and an identity transform is applied. Defaults to lambda x:x.
    :type transform: Callable[[Any], Any]
    :return: Checks each element in a list to match :code:`type_`, if any element fails the check,
        this returns False, else True.
    :rtype: bool
    """
    return all(isinstance(transform(item), type_) for item in input_)