From e3742686b13d2c9ddab20d27afc018d318d3e18c Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Thu, 17 Feb 2022 10:33:33 +0100 Subject: [PATCH] Update to redis 4.1.4 (#7247) Closes: #7245 --- stubs/redis/@tests/stubtest_allowlist.txt | 1 + .../redis/redis/commands/search/commands.pyi | 14 ++++-- stubs/redis/redis/commands/search/query.pyi | 47 +++++++++++++++++++ stubs/redis/redis/commands/search/result.pyi | 7 +++ 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 stubs/redis/redis/commands/search/query.pyi create mode 100644 stubs/redis/redis/commands/search/result.pyi diff --git a/stubs/redis/@tests/stubtest_allowlist.txt b/stubs/redis/@tests/stubtest_allowlist.txt index 380970ad8..7151eb3c2 100644 --- a/stubs/redis/@tests/stubtest_allowlist.txt +++ b/stubs/redis/@tests/stubtest_allowlist.txt @@ -1,2 +1,3 @@ redis.client.Pipeline.transaction # instance attribute has same name as superclass method +redis.commands.search.commands.SearchCommands.explain # https://github.com/redis/redis-py/pull/1997 redis.ocsp # requires cryptography to be installed diff --git a/stubs/redis/redis/commands/search/commands.pyi b/stubs/redis/redis/commands/search/commands.pyi index 9765b2f5b..5a65c9264 100644 --- a/stubs/redis/redis/commands/search/commands.pyi +++ b/stubs/redis/redis/commands/search/commands.pyi @@ -1,6 +1,13 @@ +from collections.abc import Mapping from typing import Any from typing_extensions import Literal +from .aggregation import AggregateRequest, AggregateResult, Cursor +from .query import Query +from .result import Result + +_QueryParams = Mapping[str, str | float] + NUMERIC: Literal["NUMERIC"] CREATE_CMD: Literal["FT.CREATE"] @@ -75,10 +82,11 @@ class SearchCommands: def load_document(self, id): ... def get(self, *ids): ... def info(self): ... - def search(self, query): ... - def explain(self, query): ... + def get_params_args(self, query_params: _QueryParams) -> list[Any]: ... + def search(self, query: str | Query, query_params: _QueryParams | None = ...) -> Result: ... + def explain(self, query: str | Query, query_params: _QueryParams | None = ...): ... def explain_cli(self, query): ... - def aggregate(self, query): ... + def aggregate(self, query: AggregateRequest | Cursor, query_params: _QueryParams | None = ...) -> AggregateResult: ... def profile(self, query, limited: bool = ...): ... def spellcheck(self, query, distance: Any | None = ..., include: Any | None = ..., exclude: Any | None = ...): ... def dict_add(self, name, *terms): ... diff --git a/stubs/redis/redis/commands/search/query.pyi b/stubs/redis/redis/commands/search/query.pyi new file mode 100644 index 000000000..b41ee067d --- /dev/null +++ b/stubs/redis/redis/commands/search/query.pyi @@ -0,0 +1,47 @@ +from typing import Any + +class Query: + def __init__(self, query_string) -> None: ... + def query_string(self): ... + def limit_ids(self, *ids): ... + def return_fields(self, *fields): ... + def return_field(self, field, as_field: Any | None = ...): ... + def summarize( + self, fields: Any | None = ..., context_len: Any | None = ..., num_frags: Any | None = ..., sep: Any | None = ... + ): ... + def highlight(self, fields: Any | None = ..., tags: Any | None = ...): ... + def language(self, language): ... + def slop(self, slop): ... + def in_order(self): ... + def scorer(self, scorer): ... + def get_args(self): ... + def paging(self, offset, num): ... + def verbatim(self): ... + def no_content(self): ... + def no_stopwords(self): ... + def with_payloads(self): ... + def with_scores(self): ... + def limit_fields(self, *fields): ... + def add_filter(self, flt): ... + def sort_by(self, field, asc: bool = ...): ... + def expander(self, expander): ... + +class Filter: + args: Any + def __init__(self, keyword, field, *args) -> None: ... + +class NumericFilter(Filter): + INF: str + NEG_INF: str + def __init__(self, field, minval, maxval, minExclusive: bool = ..., maxExclusive: bool = ...) -> None: ... + +class GeoFilter(Filter): + METERS: str + KILOMETERS: str + FEET: str + MILES: str + def __init__(self, field, lon, lat, radius, unit=...) -> None: ... + +class SortbyField: + args: Any + def __init__(self, field, asc: bool = ...) -> None: ... diff --git a/stubs/redis/redis/commands/search/result.pyi b/stubs/redis/redis/commands/search/result.pyi new file mode 100644 index 000000000..2908b9a61 --- /dev/null +++ b/stubs/redis/redis/commands/search/result.pyi @@ -0,0 +1,7 @@ +from typing import Any + +class Result: + total: Any + duration: Any + docs: Any + def __init__(self, res, hascontent, duration: int = ..., has_payload: bool = ..., with_scores: bool = ...) -> None: ...