Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Adar Ovadia committed Jun 26, 2024
1 parent 8f75c28 commit 7876b50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
15 changes: 8 additions & 7 deletions examples/python/client_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
RedisClusterClient,
)


def set_console_logger(level: LogLevel = LogLevel.WARN):
Logger.set_logger_config(level)

Expand Down Expand Up @@ -42,7 +41,7 @@ async def test_standalone_client(host: str = "localhost", port: int = 6379):
# Check `RedisClientConfiguration/ClusterClientConfiguration` for additional options.
config = BaseClientConfiguration(
addresses=addresses,
client_name="test_standalone_client"
client_name="test_standalone_client",
# if the server use TLS, you'll need to enable it. Otherwise the connection attempt will time out silently.
# use_tls=True
)
Expand All @@ -52,16 +51,17 @@ async def test_standalone_client(host: str = "localhost", port: int = 6379):
await send_set_and_get(client)
# Send PING to the primary node
pong = await client.custom_command(["PING"])
print(f"PONG response is = {pong}")
assert isinstance(pong, bytes)
print(f"PONG response is = {pong.decode()}")


async def test_cluster_client(host: str = "localhost", port: int = 6379):
async def test_cluster_client(host: str = "localhost", port: int = 45027):
# When in Redis is cluster mode, add address of any nodes, and the client will find all nodes in the cluster.
addresses = [NodeAddress(host, port)]
# Check `RedisClientConfiguration/ClusterClientConfiguration` for additional options.
config = BaseClientConfiguration(
addresses=addresses,
client_name="test_cluster_client"
client_name="test_cluster_client",
# if the cluster nodes use TLS, you'll need to enable it. Otherwise the connection attempt will time out silently.
# use_tls=True
)
Expand All @@ -71,10 +71,11 @@ async def test_cluster_client(host: str = "localhost", port: int = 6379):
await send_set_and_get(client)
# Send PING to all primaries (according to Redis's PING request_policy)
pong = await client.custom_command(["PING"])
print(f"PONG response is = {pong}")
assert isinstance(pong, bytes)
print(f"PONG response is = {pong.decode()}")
# Send INFO REPLICATION with routing option to all nodes
info_repl_resps = await client.custom_command(["INFO", "REPLICATION"], AllNodes())
print(f"INFO REPLICATION responses to all nodes are = {info_repl_resps}")
print(f"INFO REPLICATION responses to all nodes are = {info_repl_resps!r}")


async def main():
Expand Down
7 changes: 0 additions & 7 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ fn glide(_py: Python, m: &PyModule) -> PyResult<()> {
Value::Okay => Ok("OK".into_py(py)),
Value::Int(num) => Ok(num.into_py(py)),
Value::BulkString(data) => {
// TODO: for now, and in order to keep the current tests to work,
// we still return a UTF-8 encoded string instead of `&[u8]`. This needs
// to be changed

// let value_str = String::from_utf8_lossy(&data);
// Ok(value_str.into_py(py))

let data_bytes = PyBytes::new(py, &data);
Ok(data_bytes.into_py(py))
}
Expand Down

0 comments on commit 7876b50

Please sign in to comment.