def METHOD_NAME(minimum, maximum, value, variable_name):
    if value is None:
        value = maximum
    elif not isinstance(value, int):
        raise InvalidArgument(
            f"Expected integer but {variable_name} is a {type(value).__name__}"
        )
    elif not minimum <= value <= maximum:
        raise InvalidArgument(
            f"Invalid value {minimum!r} < {variable_name}={value!r} < {maximum!r}"
        )
    return value