def check_type()

in mozci/console/commands/push.py [0:0]


def check_type(parameter_type, hint, value):
    try:
        if parameter_type == bool:
            parameter = value not in [False, 0, "0", "False", "false", "f"]
        elif parameter_type == Optional[Tuple[int, int]]:
            match = re.match(TWO_INTS_TUPLE_REGEXP, value)

            if not match or len(match.groups()) != 2:
                raise ValueError

            parameter = tuple([int(number) for number in match.groups()])
        else:
            parameter = parameter_type(value)
    except ValueError:
        raise Exception(
            f"Provided {hint} should be a {parameter_type.__name__ if hasattr(parameter_type, '__name__') else parameter_type}."
        )

    return parameter