def to_type(type_string, variable_name) -> Type:
    """
    Returns a :class:`Type` object of a given type name. Lookup is done via :var:`code_generator_settings.CLASS_TYPE_PATHS`

    :param type_string: The type as string. E.g "bool". Need to be valid python.
    :param variable_name: Only for logging, if an unrecognized type is found.
    :return: a :class:`Type` instance
    :rtype: Type
    """
    # type_string = type_string.strip()
    # remove "list of " and set .is_list accordingly.
    # is_list, type_string = can_strip_prefix(type_string, "list of ")
    # var_type = Type(string=type_string, is_list=is_list)

    var_type = Type(type_string)
    # remove "list of " and set .is_list accordingly.
    is_list = True
    while is_list:
        is_list, var_type.string = can_strip_prefix(var_type.string, "list of ")
        if is_list:
            var_type.is_list += 1
        # end if
    # end for
    if var_type.string == "True":
        var_type.string = "bool"
        var_type.always_is_value = "True"
    # end if
    if var_type.string in ["int", "bool", "float", "object", "None", "str"]:
        var_type.is_builtin = True
    elif var_type.string == "unicode_type":
        var_type.string = "unicode_type"
        var_type.is_builtin = False
        var_type.import_path = "luckydonaldUtils.encoding"
        var_type.description = "py2: unicode, py3: str"
    elif var_type.string in CLASS_TYPE_PATHS:
        var_type.import_path = CLASS_TYPE_PATHS[var_type.string][CLASS_TYPE_PATHS__IMPORT].rstrip(".")
        var_type.is_builtin = False
    else:
        logger.warn(
            "Added unrecognized type in param <{var}>: {type!r}".format(var=variable_name, type=var_type.string))
    # end if
    return var_type
def to_type ( type_string , variable_name ) -> Type : var_type = Type ( type_string ) is_list = True while is_list : is_list , var_type . string = can_strip_prefix ( var_type . string , "list of " ) if is_list : var_type . is_list += 1 if var_type . string == "True" : var_type . string = "bool" var_type . always_is_value = "True" if var_type . string in [ "int" , "bool" , "float" , "object" , "None" , "str" ] : var_type . is_builtin = True elif var_type . string == "unicode_type" : var_type . string = "unicode_type" var_type . is_builtin = False var_type . import_path = "luckydonaldUtils.encoding" var_type . description = "py2: unicode, py3: str" elif var_type . string in CLASS_TYPE_PATHS : var_type . import_path = CLASS_TYPE_PATHS [ var_type . string ] [ CLASS_TYPE_PATHS__IMPORT ] . rstrip ( "." ) var_type . is_builtin = False else : logger . warn ( "Added unrecognized type in param <{var}>: {type!r}" . format ( var = variable_name , type = var_type . string ) ) return var_type
Returns a :class:`Type` object of a given type name. Lookup is done via :var:`code_generator_settings.CLASS_TYPE_PATHS`

    :param type_string: The type as string. E.g "bool". Need to be valid python.
    :param variable_name: Only for logging, if an unrecognized type is found.
    :return: a :class:`Type` instance
    :rtype: Type