2121 TEMPORARY ,
2222)
2323from redis .commands .search .field import Field
24- from redis .commands .search .index_definition import IndexDefinition
25- from redis .commands .search .profile_information import ProfileInformation
24+
25+ # Redis 5.x compatibility (6 fixed the import path)
26+ try :
27+ from redis .commands .search .index_definition import ( # type: ignore[import-untyped]
28+ IndexDefinition ,
29+ )
30+ except ModuleNotFoundError :
31+ from redis .commands .search .indexDefinition import IndexDefinition
32+
2633from redis .commands .search .query import Query
2734from redis .commands .search .result import Result
2835
@@ -255,11 +262,12 @@ async def async_cluster_create_index(
255262 return await default_node .execute_command (* args )
256263
257264
265+ # TODO: The return type is incorrect because 5.x doesn't have "ProfileInformation"
258266def cluster_search (
259267 client : Search ,
260268 query : Union [str , Query ],
261269 query_params : Optional [Dict [str , Union [str , int , float , bytes ]]] = None ,
262- ) -> Union [Result , Pipeline , ProfileInformation ]:
270+ ) -> Union [Result , Pipeline , Any ]: # type: ignore[type-arg]
263271 args , query = client ._mk_query_args (query , query_params = query_params )
264272 st = time .monotonic ()
265273
@@ -278,11 +286,12 @@ def cluster_search(
278286 )
279287
280288
289+ # TODO: The return type is incorrect because 5.x doesn't have "ProfileInformation"
281290async def async_cluster_search (
282291 client : AsyncSearch ,
283292 query : Union [str , Query ],
284293 query_params : Optional [Dict [str , Union [str , int , float , bytes ]]] = None ,
285- ) -> Union [Result , Pipeline , ProfileInformation ]:
294+ ) -> Union [Result , Pipeline , Any ]: # type: ignore[type-arg]
286295 args , query = client ._mk_query_args (query , query_params = query_params )
287296 st = time .monotonic ()
288297
0 commit comments