Skip to content

Commit daf2a61

Browse files
author
Nitin Kanukolanu
committed
Lint passes
1 parent 9873576 commit daf2a61

File tree

3 files changed

+5
-122
lines changed

3 files changed

+5
-122
lines changed

redisvl/redis/connection.py

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ def check_vector_capabilities(client: SyncRedisClient) -> VectorSupport:
145145
Returns:
146146
VectorSupport with version info and supported features
147147
"""
148-
info = client.info("server")
149-
redis_version = info.get("redis_version", "0.0.0")
148+
info = client.info("server") # type: ignore[union-attr]
149+
redis_version = info.get("redis_version", "0.0.0") # type: ignore[union-attr]
150150

151151
modules = RedisConnectionFactory.get_modules(client)
152152
search_ver = modules.get("search", 0)
@@ -173,8 +173,8 @@ async def check_vector_capabilities_async(client: AsyncRedisClient) -> VectorSup
173173
Returns:
174174
VectorSupport with version info and supported features
175175
"""
176-
info = await client.info("server")
177-
redis_version = info.get("redis_version", "0.0.0")
176+
info = await client.info("server") # type: ignore[union-attr]
177+
redis_version = info.get("redis_version", "0.0.0") # type: ignore[union-attr]
178178

179179
modules = await RedisConnectionFactory.get_modules_async(client)
180180
search_ver = modules.get("search", 0)
@@ -192,66 +192,6 @@ async def check_vector_capabilities_async(client: AsyncRedisClient) -> VectorSup
192192
)
193193

194194

195-
def supports_svs_vamana(client: SyncRedisClient) -> bool:
196-
"""Check if Redis server supports SVS-VAMANA algorithm.
197-
198-
SVS-Vamana requires:
199-
- Redis version >= 8.2.0
200-
- RediSearch version >= 2.8.10 (20810)
201-
202-
Args:
203-
client: Sync Redis client instance
204-
205-
Returns:
206-
bool: True if SVS-VAMANA is supported, False otherwise
207-
"""
208-
info = client.info()
209-
redis_version = info.get("redis_version", "0.0.0")
210-
if not compare_versions(redis_version, SVS_MIN_REDIS_VERSION):
211-
return False
212-
213-
# Check module versions
214-
modules = unpack_redis_modules(convert_bytes(client.module_list()))
215-
for module in SVS_REQUIRED_MODULES:
216-
module_name = module["name"]
217-
required_version = module["ver"]
218-
if module_name not in modules:
219-
return False
220-
if modules[module_name] < required_version:
221-
return False
222-
return True
223-
224-
225-
async def async_supports_svs_vamana(client: AsyncRedisClient) -> bool:
226-
"""Check if Redis server supports SVS-VAMANA algorithm asynchronously.
227-
228-
SVS-Vamana requires:
229-
- Redis version >= 8.2.0
230-
- RediSearch version >= 2.8.10 (20810)
231-
232-
Args:
233-
client: Sync Redis client instance
234-
235-
Returns:
236-
bool: True if SVS-VAMANA is supported, False otherwise
237-
"""
238-
info = await client.info()
239-
redis_version = info.get("redis_version", "0.0.0")
240-
if not compare_versions(redis_version, SVS_MIN_REDIS_VERSION):
241-
return False
242-
243-
# Check module versions
244-
modules = unpack_redis_modules(convert_bytes(await client.module_list()))
245-
for module in SVS_REQUIRED_MODULES:
246-
module_name = module["name"]
247-
required_version = module["ver"]
248-
if module_name not in modules:
249-
return False
250-
if modules[module_name] < required_version:
251-
return False
252-
return True
253-
254-
255195
def get_address_from_env() -> str:
256196
"""Get Redis URL from environment variable."""
257197
redis_url = os.getenv(REDIS_URL_ENV_VAR)
@@ -558,6 +498,7 @@ async def _get_aredis_connection(
558498
"""
559499
url = url or get_address_from_env()
560500

501+
client: AsyncRedisClient
561502
if url.startswith("redis+sentinel"):
562503
client = RedisConnectionFactory._redis_sentinel_client(
563504
url, AsyncRedis, **kwargs

tests/unit/test_fields.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,6 @@ def test_field_factory_with_new_attributes():
448448
assert vector_field.attrs.index_missing == True
449449

450450

451-
# ==================== SVS-VAMANA TESTS ====================
452-
453-
454451
def test_svs_vector_field_creation():
455452
"""Test basic SVS-VAMANA vector field creation."""
456453
svs_field = create_svs_vector_field()
@@ -643,9 +640,6 @@ def test_svs_vector_field_leanvec8x8_with_reduce():
643640
assert redis_field.args[redis_field.args.index("REDUCE") + 1] == 512
644641

645642

646-
# ==================== SVS-VAMANA INDEX VALIDATION TESTS ====================
647-
648-
649643
def test_uses_svs_vamana_true():
650644
"""Test _uses_svs_vamana returns True for SVS schema."""
651645
schema_dict = {

tests/unit/test_svs_capability_detection.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,12 @@
1212
from redisvl.exceptions import RedisModuleVersionError
1313
from redisvl.redis.connection import (
1414
VectorSupport,
15-
async_supports_svs_vamana,
1615
check_vector_capabilities,
1716
check_vector_capabilities_async,
1817
compare_versions,
1918
format_module_version,
20-
supports_svs_vamana,
2119
)
2220

23-
# ============================================================================
24-
# Helper Function Tests
25-
# ============================================================================
26-
2721

2822
def test_format_version_20810():
2923
"""Test formatting version 20810 -> 2.8.10"""
@@ -44,11 +38,6 @@ def test_compare_lesser_version():
4438
assert compare_versions("8.2.0", "8.2.1") is False
4539

4640

47-
# ============================================================================
48-
# check_vector_capabilities Tests
49-
# ============================================================================
50-
51-
5241
def test_check_vector_capabilities_supported():
5342
"""Test check_vector_capabilities when SVS is supported."""
5443
mock_client = Mock()
@@ -118,47 +107,6 @@ async def test_check_vector_capabilities_async_supported():
118107
assert caps.svs_vamana_supported is True
119108

120109

121-
# ============================================================================
122-
# supports_svs_vamana Tests
123-
# ============================================================================
124-
125-
126-
def test_supports_svs_vamana_true():
127-
"""Test supports_svs_vamana returns True when supported."""
128-
mock_client = Mock()
129-
mock_client.info.return_value = {"redis_version": "8.2.0"}
130-
mock_client.module_list.return_value = [
131-
{"name": b"search", "ver": 20810},
132-
{"name": b"searchlight", "ver": 20810},
133-
]
134-
135-
assert supports_svs_vamana(mock_client) is True
136-
137-
138-
def test_supports_svs_vamana_false_old_redis():
139-
"""Test supports_svs_vamana returns False with old Redis."""
140-
mock_client = Mock()
141-
mock_client.info.return_value = {"redis_version": "7.2.4"}
142-
mock_client.module_list.return_value = [
143-
{"name": b"search", "ver": 20810},
144-
]
145-
146-
assert supports_svs_vamana(mock_client) is False
147-
148-
149-
def test_supports_svs_vamana_exception_handling():
150-
"""Test supports_svs_vamana handles exceptions gracefully."""
151-
mock_client = Mock()
152-
mock_client.info.side_effect = Exception("Connection error")
153-
154-
assert supports_svs_vamana(mock_client) is False
155-
156-
157-
# ============================================================================
158-
# Exception Tests
159-
# ============================================================================
160-
161-
162110
def test_for_svs_vamana_error_message():
163111
"""Test RedisModuleVersionError.for_svs_vamana creates proper exception."""
164112
caps = VectorSupport(

0 commit comments

Comments
 (0)