def read_args_from_dict(input_dict, arg_names, arg_types):
    """Reads *mandatory* arguments from an input dictionary.
    Useful for reading positional arguments for a function.

    All the names in arg_names must be present as keys of
    input_dict, and the number of elements of arg_names and
    arg_types must match. However, an item of arg_types can
    be passed as None to avoid its type cast.

    Returns a tuple with the gathered and casted parameters,
    sorted according to arg_names.

    Parameters
    ----------
    input_dict : dict
    arg_names : list, tuple
    arg_types : list, tuple
    """
    if len(arg_names) != len(arg_types):
        raise ValueError("Hey, the number of argument names ({}) and the "
                         "number of argument types ({}) do not match!"
                         "".format(len(arg_names), len(arg_types)))

    args = []

    for name, cast in zip(arg_names, arg_types):
        if cast is None:
            args.append(input_dict[name])
        else:
            args.append(cast(input_dict[name]))

    return tuple(args)