transforms a snakecase given string to camelcase or pascalcase if indicated defaults to not use pascal snaketocamelcasesomerandomstring somerandomstring snaketocamelcasesomerandomstring usepascaltrue somerandomstring snaketocamelcasesomerandomstringwithnumbers123 somerandomstringwithnumbers123 snaketocamelcasesomerandomstringwithnumbers123 usepascaltrue somerandomstringwithnumbers123 snaketocamelcase123 traceback most recent call last valueerror expected string as input found class int snaketocamelcasesomestring usepascaltrue traceback most recent call last valueerror expected boolean as usepascal parameter found class str transforms a snake_case given string to camelcase or pascalcase if indicated defaults to not use pascal snake_to_camel_case some_random_string somerandomstring snake_to_camel_case some_random_string use_pascal true somerandomstring snake_to_camel_case some_random_string_with_numbers_123 somerandomstringwithnumbers123 snake_to_camel_case some_random_string_with_numbers_123 use_pascal true somerandomstringwithnumbers123 snake_to_camel_case 123 traceback most recent call last valueerror expected string as input found class int snake_to_camel_case some_string use_pascal true traceback most recent call last valueerror expected boolean as use_pascal parameter found class str
def snake_to_camel_case(input_str: str, use_pascal: bool = False) -> str:
    

    if not isinstance(input_str, str):
        msg = f"Expected string as input, found {type(input_str)}"
        raise ValueError(msg)
    if not isinstance(use_pascal, bool):
        msg = f"Expected boolean as use_pascal parameter, found {type(use_pascal)}"
        raise ValueError(msg)

    words = input_str.split("_")

    start_index = 0 if use_pascal else 1

    words_to_capitalize = words[start_index:]

    capitalized_words = [word[0].upper() + word[1:] for word in words_to_capitalize]

    initial_word = "" if use_pascal else words[0]

    return "".join([initial_word, *capitalized_words])


if __name__ == "__main__":
    from doctest import testmod

    testmod()