From 267a3a41b00e1191e20c4e3ba998cd071e5a7c38 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Tue, 7 Jan 2025 11:30:41 -0800 Subject: [PATCH 1/4] FIx CI Signed-off-by: Yury-Fridlyand --- deny.toml | 5 +- python/Cargo.toml | 6 +- python/python/tests/test_async_client.py | 4 +- python/src/lib.rs | 88 ++++++++++++++---------- 4 files changed, 61 insertions(+), 42 deletions(-) diff --git a/deny.toml b/deny.toml index f97a82f0c8..060b39414e 100644 --- a/deny.toml +++ b/deny.toml @@ -50,7 +50,9 @@ unsound = "deny" # output a note when they are encountered. ignore = [ # Unmaintained dependency error that needs more attention due to nested dependencies - "RUSTSEC-2024-0370" + "RUSTSEC-2024-0370", + "RUSTSEC-2024-0384", + "RUSTSEC-2024-0388", ] # Threshold for security vulnerabilities, any vulnerability with a CVSS score # lower than the range specified will be ignored. Note that ignored advisories @@ -84,6 +86,7 @@ allow = [ "BSD-2-Clause", "BSD-3-Clause", "Unicode-DFS-2016", + "Unicode-3.0", "ISC", "OpenSSL" ] diff --git a/python/Cargo.toml b/python/Cargo.toml index 16632945bb..877953af51 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -11,7 +11,11 @@ name = "glide" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "^0.20", features = ["extension-module", "num-bigint"] } +pyo3 = { version = "^0.22", features = [ + "extension-module", + "num-bigint", + "gil-refs", +] } bytes = { version = "1.6.0" } redis = { path = "../submodules/redis-rs/redis", features = ["aio", "tokio-comp", "connection-manager","tokio-rustls-comp"] } glide-core = { path = "../glide-core", features = ["socket-layer"] } diff --git a/python/python/tests/test_async_client.py b/python/python/tests/test_async_client.py index e9897c7b2d..e9ebc3ed6a 100644 --- a/python/python/tests/test_async_client.py +++ b/python/python/tests/test_async_client.py @@ -9691,7 +9691,7 @@ async def cluster_route_custom_command_slot_route( route_class = SlotKeyRoute if is_slot_key else SlotIdRoute route_second_arg = "foo" if is_slot_key else 4000 primary_res = await glide_client.custom_command( - ["CLUSTER", "NODES"], route_class(SlotType.PRIMARY, route_second_arg) + ["CLUSTER", "NODES"], route_class(SlotType.PRIMARY, route_second_arg) # type: ignore ) assert isinstance(primary_res, bytes) primary_res = primary_res.decode() @@ -9704,7 +9704,7 @@ async def cluster_route_custom_command_slot_route( expected_primary_node_id = node_line.split(" ")[0] replica_res = await glide_client.custom_command( - ["CLUSTER", "NODES"], route_class(SlotType.REPLICA, route_second_arg) + ["CLUSTER", "NODES"], route_class(SlotType.REPLICA, route_second_arg) # type: ignore ) assert isinstance(replica_res, bytes) replica_res = replica_res.decode() diff --git a/python/src/lib.rs b/python/src/lib.rs index 6209a5b894..19e635c100 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -1,8 +1,7 @@ +// Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 + use bytes::Bytes; use glide_core::client::FINISHED_SCAN_CURSOR; -/** - * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 - */ use glide_core::start_socket_listener; use glide_core::MAX_REQUEST_ARGS_LENGTH; use pyo3::exceptions::PyTypeError; @@ -10,12 +9,13 @@ use pyo3::prelude::*; use pyo3::types::{PyAny, PyBool, PyBytes, PyDict, PyFloat, PyList, PySet}; use pyo3::Python; use redis::Value; +use std::sync::Arc; pub const DEFAULT_TIMEOUT_IN_MILLISECONDS: u32 = glide_core::client::DEFAULT_RESPONSE_TIMEOUT.as_millis() as u32; pub const MAX_REQUEST_ARGS_LEN: u32 = MAX_REQUEST_ARGS_LENGTH as u32; -#[pyclass] +#[pyclass(eq, eq_int)] #[derive(PartialEq, Eq, PartialOrd, Clone)] pub enum Level { Error = 0, @@ -47,6 +47,7 @@ pub struct ClusterScanCursor { #[pymethods] impl ClusterScanCursor { #[new] + #[pyo3(signature = (new_cursor=None))] fn new(new_cursor: Option) -> Self { match new_cursor { Some(cursor) => ClusterScanCursor { cursor }, @@ -77,10 +78,10 @@ pub struct Script { #[pymethods] impl Script { #[new] - fn new(code: &PyAny) -> PyResult { + fn new(code: &Bound) -> PyResult { let hash = if let Ok(code_str) = code.extract::() { glide_core::scripts_container::add_script(code_str.as_bytes()) - } else if let Ok(code_bytes) = code.extract::<&PyBytes>() { + } else if let Ok(code_bytes) = code.extract::>() { glide_core::scripts_container::add_script(code_bytes.as_bytes()) } else { return Err(PyTypeError::new_err( @@ -102,7 +103,7 @@ impl Script { /// A Python module implemented in Rust. #[pymodule] -fn glide(_py: Python, m: &PyModule) -> PyResult<()> { +fn glide(_py: Python, m: &Bound) -> PyResult<()> { m.add_class::()?; m.add_class::