federated/main.py
def validate_type_input(input_string: str, default: Any, inp_type: type) -> Any:
    """Custom input with validation for ints, floats, and bools.

    Args:
        input_string (str): Prompt string for input.\n
        default (Any): Default value.\n
        inp_type (type): Type to convert to.

    Returns:
        Any: Converted input value.
    """

    prompts = chain(
        [input_string + f"(default: {boldify(default)}): "],
        repeat(f"Input must be of type {inp_type}. Try again: "),
    )
    replies = map(input, prompts)
    valid_response = next(filter(lambda x: check_type(x, inp_type) or x == "", replies))

    if valid_response == "":
        if inp_type == bool:
            return eval(default)
        return default

    if inp_type == bool:
        return eval(valid_response)

    return inp_type(valid_response)
Custom input with validation for ints, floats, and bools.

    Args:
        input_string (str): Prompt string for input.\n
        default (Any): Default value.\n
        inp_type (type): Type to convert to.

    Returns:
        Any: Converted input value.
    
Custom input with validation for ints, floats, and bools.
Custom input with validation for ints floats and bools .
def validate_type_input(input_string: str, default: Any, inp_type: type) -> Any:
    prompts = chain(
        [input_string + f"(default: {boldify(default)}): "],
        repeat(f"Input must be of type {inp_type}. Try again: "),
    )
    replies = map(input, prompts)
    valid_response = next(filter(lambda x: check_type(x, inp_type) or x == "", replies))
    if valid_response == "":
        if inp_type == bool:
            return eval(default)
        return default
    if inp_type == bool:
        return eval(valid_response)
    return inp_type(valid_response)
def validate_type_input ( input_string : str , default : Any , inp_type : type ) -> Any : prompts = chain ( [ input_string + f"(default: {boldify(default)}): " ] , repeat ( f"Input must be of type {inp_type}. Try again: " ) , ) replies = map ( input , prompts ) valid_response = next ( filter ( lambda x : check_type ( x , inp_type ) or x == "" , replies ) ) if valid_response == "" : if inp_type == bool : return eval ( default ) return default if inp_type == bool : return eval ( valid_response ) return inp_type ( valid_response )
Custom input with validation for ints, floats, and bools.
Custom input with validation for ints floats and bools .
"""Custom input with validation for ints, floats, and bools.

    Args:
        input_string (str): Prompt string for input.\n
        default (Any): Default value.\n
        inp_type (type): Type to convert to.

    Returns:
        Any: Converted input value.
    """
Converted input value.
Converted input value .
Any
input_string
str
Prompt string for input.\n
Prompt string for input . \ n
default
Any
None
inp_type
type
Type to convert to.
Type to convert to .