from typing import Tuple
from typing import List
from typing import Any


def _extract_bracket_params(meta_type: str) -> Tuple[str, List[Any]]:
    """
    Gets parameters from the string representation of the type

    Args:
        meta_type (str): The string name of the metadata type

    Returns:
        Tuple[str, List[Any]]: A tuple, first arg is a string of the type
        name only and then the second value is a list of values (if any)
        inside the brackets of the meta_type. e.g. "int64" returns ("int64", [])
        and "decimal128(1,2)" returns ("decimal128", [1, 2])
    """
    is_decimal_type = meta_type.startswith("decimal128")
    is_binary_type = meta_type.startswith("binary")

    if "(" in meta_type:
        attr_name, value_str = meta_type.split("(", 1)
        value_str = value_str.split(")")[0]
        values = value_str.split(",")
        if not any([bool(v) for v in values]):
            values = []

        # cast input to int for specific types
        if (is_decimal_type or is_binary_type) and values:
            values = [int(v.strip()) for v in values]
    else:
        attr_name = meta_type
        values = []
    return attr_name, values