Skip to content

Commit 1449a8d

Browse files
committed
Consistently raise ImportError for missing dependencies
1 parent a1a5042 commit 1449a8d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

redisvl/index/index.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def _validate_hybrid_query(self, query: Any) -> None:
288288

289289
from redisvl.query.hybrid import HybridQuery
290290
except (ImportError, ModuleNotFoundError):
291-
raise NotImplementedError(_HYBRID_SEARCH_ERROR_MESSAGE)
291+
raise ImportError(_HYBRID_SEARCH_ERROR_MESSAGE)
292292

293293
if not isinstance(query, HybridQuery):
294294
raise TypeError(f"query must be of type HybridQuery, got {type(query)}")
@@ -1054,7 +1054,7 @@ def _hybrid_search(self, query: HybridQuery, **kwargs) -> List[Dict[str, Any]]:
10541054
self._validate_hybrid_query(query)
10551055

10561056
if not hasattr(index, "hybrid_search"):
1057-
raise NotImplementedError(_HYBRID_SEARCH_ERROR_MESSAGE)
1057+
raise ImportError(_HYBRID_SEARCH_ERROR_MESSAGE)
10581058

10591059
results = index.hybrid_search(
10601060
query=query.query,
@@ -1928,7 +1928,7 @@ async def _hybrid_search(
19281928
self._validate_hybrid_query(query)
19291929

19301930
if not hasattr(index, "hybrid_search"):
1931-
raise NotImplementedError(_HYBRID_SEARCH_ERROR_MESSAGE)
1931+
raise ImportError(_HYBRID_SEARCH_ERROR_MESSAGE)
19321932

19331933
results = await index.hybrid_search(
19341934
query=query.query,

tests/integration/test_hybrid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,5 +512,5 @@ def test_hybrid_query_not_available(index):
512512
REDIS_HYBRID_AVAILABLE, reason="Requires hybrid search to NOT be available"
513513
)
514514
def test_hybrid_search_method_missing(index):
515-
with pytest.raises(NotImplementedError):
515+
with pytest.raises(ImportError):
516516
index.query(None)

0 commit comments

Comments
 (0)