Skip to content

Redis Search/Aggregate improved type annotations #3676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions redis/commands/search/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Reducer:

NAME = None

def __init__(self, *args: List[str]) -> None:
def __init__(self, *args: str) -> None:
self._args = args
self._field = None
self._alias = None
Expand Down Expand Up @@ -116,7 +116,7 @@ def __init__(self, query: str = "*") -> None:
self._add_scores = False
self._scorer = "TFIDF"

def load(self, *fields: List[str]) -> "AggregateRequest":
def load(self, *fields: str) -> "AggregateRequest":
"""
Indicate the fields to be returned in the response. These fields are
returned in addition to any others implicitly specified.
Expand Down Expand Up @@ -223,7 +223,7 @@ def limit(self, offset: int, num: int) -> "AggregateRequest":
self._aggregateplan.extend(_limit.build_args())
return self

def sort_by(self, *fields: List[str], **kwargs) -> "AggregateRequest":
def sort_by(self, *fields: str, **kwargs) -> "AggregateRequest":
"""
Indicate how the results should be sorted. This can also be used for
*top-N* style queries
Expand Down
6 changes: 3 additions & 3 deletions redis/commands/search/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def explain_cli(self, query: Union[str, Query]): # noqa

def aggregate(
self,
query: Union[str, Query],
query: Union[AggregateRequest, Cursor],
query_params: Dict[str, Union[str, int, float]] = None,
):
"""
Expand Down Expand Up @@ -573,7 +573,7 @@ def aggregate(
)

def _get_aggregate_result(
self, raw: List, query: Union[str, Query, AggregateRequest], has_cursor: bool
self, raw: List, query: Union[AggregateRequest, Cursor], has_cursor: bool
):
if has_cursor:
if isinstance(query, Cursor):
Expand Down Expand Up @@ -967,7 +967,7 @@ async def search(

async def aggregate(
self,
query: Union[str, Query],
query: Union[AggregateResult, Cursor],
query_params: Dict[str, Union[str, int, float]] = None,
):
"""
Expand Down
Loading