Skip to content

Commit 4a54f41

Browse files
committed
fix pr comments
1 parent da2b489 commit 4a54f41

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

redis/commands/search/commands.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,11 @@ def info(self):
384384
it = map(to_string, res)
385385
return dict(zip(it, it))
386386

387-
def get_params_args(self, query_params: Dict[str, Union[str, int, float]]):
387+
def get_params_args(
388+
self, query_params: Union[Dict[str, Union[str, int, float]], None]
389+
):
390+
if query_params is None:
391+
return []
388392
args = []
389393
if len(query_params) > 0:
390394
args.append("params")
@@ -404,8 +408,7 @@ def _mk_query_args(self, query, query_params: Dict[str, Union[str, int, float]])
404408
raise ValueError(f"Bad query type {type(query)}")
405409

406410
args += query.get_args()
407-
if query_params is not None:
408-
args += self.get_params_args(query_params)
411+
args += self.get_params_args(query_params)
409412

410413
return args, query
411414

@@ -480,8 +483,7 @@ def aggregate(
480483
cmd = [CURSOR_CMD, "READ", self.index_name] + query.build_args()
481484
else:
482485
raise ValueError("Bad query", query)
483-
if query_params is not None:
484-
cmd += self.get_params_args(query_params)
486+
cmd += self.get_params_args(query_params)
485487

486488
raw = self.execute_command(*cmd)
487489
return self._get_aggregate_result(raw, query, has_cursor)
@@ -506,16 +508,17 @@ def _get_aggregate_result(self, raw, query, has_cursor):
506508

507509
return AggregateResult(rows, cursor, schema)
508510

509-
def profile(self, query, query_params=None, limited=False):
511+
def profile(self, query, limited=False, query_params=None):
510512
"""
511513
Performs a search or aggregate command and collects performance
512514
information.
513515
514516
### Parameters
515517
516-
**query**: This can be either an `AggregateRequest`, `Query` or
517-
string.
518+
**query**: This can be either an `AggregateRequest`, `Query` or string.
518519
**limited**: If set to True, removes details of reader iterator.
520+
**query_params**: Define one or more value parameters.
521+
Each parameter has a name and a value.
519522
520523
"""
521524
st = time.time()
@@ -530,8 +533,7 @@ def profile(self, query, query_params=None, limited=False):
530533
elif isinstance(query, Query):
531534
cmd[2] = "SEARCH"
532535
cmd += query.get_args()
533-
if query_params is not None:
534-
cmd += self.get_params_args(query_params)
536+
cmd += self.get_params_args(query_params)
535537
else:
536538
raise ValueError("Must provide AggregateRequest object or " "Query object.")
537539

@@ -930,8 +932,7 @@ async def aggregate(
930932
cmd = [CURSOR_CMD, "READ", self.index_name] + query.build_args()
931933
else:
932934
raise ValueError("Bad query", query)
933-
if query_params is not None:
934-
cmd += self.get_params_args(query_params)
935+
cmd += self.get_params_args(query_params)
935936

936937
raw = await self.execute_command(*cmd)
937938
return self._get_aggregate_result(raw, query, has_cursor)

0 commit comments

Comments
 (0)