def beta_argv_arg_to_string()

in chz/blueprint/_argv.py [0:0]


def beta_argv_arg_to_string(key: str, value: Any) -> str:
    if isinstance(value, chz.blueprint.Castable):
        return f"{key}={value.value}"
    if isinstance(value, chz.blueprint.Reference):
        return f"{key}@={value.ref}"
    if isinstance(value, (types.FunctionType, type)):
        return f"{key}={type_repr(value)}"
    if isinstance(value, str):
        return f"{key}={value}"
    if isinstance(value, (int, float, bool)) or value is None:
        return f"{key}={repr(value)}"
    # Probably safe to use repr here, but I'm curious to see how people end up using this
    raise NotImplementedError(
        f"TODO: beta_blueprint_to_argv does not currently convert {value!r} of "
        f"type {type(value)} to string"
    )