def _recast_primitive()

in src/cloudformation_cli_python_lib/recast.py [0:0]


def _recast_primitive(cls: Any, k: str, v: Any) -> Any:
    if cls is typing.Any:
        # If the type is Any, we cannot guess what the original type was, so we leave
        # it as a string
        return v
    if cls == bool and isinstance(v, str):
        if v.lower() == "true":
            return True
        if v.lower() == "false":
            return False
        raise InvalidRequest(f'value for {k} "{v}" is not boolean')
    return cls(v)