Skip to content

Commit 46600b0

Browse files
committed
More rename, add few types
1 parent 77bce4d commit 46600b0

File tree

10 files changed

+71
-30
lines changed

10 files changed

+71
-30
lines changed

valkey/cluster.pyi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ from types import TracebackType
55
from typing import Any, ClassVar, Literal, NoReturn, Protocol
66
from typing_extensions import Self
77

8-
from redis.client import CaseInsensitiveDict, PubSub, Valkey, _ParseResponseOptions
9-
from redis.commands import CommandsParser, ValkeyClusterCommands
10-
from redis.commands.core import _StrType
11-
from redis.connection import BaseParser, Connection, ConnectionPool, Encoder, _ConnectionPoolOptions, _Encodable
12-
from redis.exceptions import MovedError, ValkeyError
13-
from redis.retry import Retry
14-
from redis.typing import EncodableT
8+
from valkey.client import CaseInsensitiveDict, PubSub, Valkey, _ParseResponseOptions
9+
from valkey.commands import CommandsParser, ValkeyClusterCommands
10+
from valkey.commands.core import _StrType
11+
from valkey.connection import BaseParser, Connection, ConnectionPool, Encoder, _ConnectionPoolOptions, _Encodable
12+
from valkey.exceptions import MovedError, ValkeyError
13+
from valkey.retry import Retry
14+
from valkey.typing import EncodableT
1515

1616
def get_node_name(host: str, port: str | int) -> str: ...
17-
def get_connection(redis_node: Valkey[Any], *args, **options: _ConnectionPoolOptions) -> Connection: ...
17+
def get_connection(valkey_node: Valkey[Any], *args, **options: _ConnectionPoolOptions) -> Connection: ...
1818
def parse_scan_result(command: Unused, res, **options): ...
1919
def parse_pubsub_numsub(command: Unused, res, **options: Unused): ...
2020
def parse_cluster_slots(resp, **options) -> dict[tuple[int, int], dict[str, Any]]: ...
@@ -82,7 +82,7 @@ class ValkeyCluster(AbstractValkeyCluster, ValkeyClusterCommands[_StrType]):
8282
@classmethod
8383
def from_url(cls, url: str, **kwargs) -> Self: ...
8484
def on_connect(self, connection: Connection) -> None: ...
85-
def get_redis_connection(self, node: ClusterNode) -> Valkey[Any]: ...
85+
def get_valkey_connection(self, node: ClusterNode) -> Valkey[Any]: ...
8686
def get_node(
8787
self, host: str | None = None, port: str | int | None = None, node_name: str | None = None
8888
) -> ClusterNode | None: ...
@@ -120,9 +120,9 @@ class ClusterNode:
120120
port: int
121121
name: str
122122
server_type: str | None
123-
redis_connection: Valkey[Incomplete] | None
123+
valkey_connection: Valkey[Incomplete] | None
124124
def __init__(
125-
self, host: str, port: int, server_type: str | None = None, redis_connection: Valkey[Incomplete] | None = None
125+
self, host: str, port: int, server_type: str | None = None, valkey_connection: Valkey[Incomplete] | None = None
126126
) -> None: ...
127127
def __eq__(self, obj: object) -> bool: ...
128128
def __del__(self) -> None: ...
@@ -163,8 +163,8 @@ class NodesManager:
163163
def get_nodes_by_server_type(self, server_type: str) -> list[ClusterNode]: ...
164164
def populate_startup_nodes(self, nodes: Iterable[ClusterNode]) -> None: ...
165165
def check_slots_coverage(self, slots_cache: dict[str, list[ClusterNode]]) -> bool: ...
166-
def create_redis_connections(self, nodes: Iterable[ClusterNode]) -> None: ...
167-
def create_redis_node(self, host: str, port: int | str, **kwargs: Any) -> Valkey[Incomplete]: ...
166+
def create_valkey_connections(self, nodes: Iterable[ClusterNode]) -> None: ...
167+
def create_valkey_node(self, host: str, port: int | str, **kwargs: Any) -> Valkey[Incomplete]: ...
168168
def initialize(self) -> None: ...
169169
def close(self) -> None: ...
170170
def reset(self) -> None: ...
@@ -175,7 +175,7 @@ class ClusterPubSub(PubSub):
175175
cluster: ValkeyCluster[Any]
176176
def __init__(
177177
self,
178-
redis_cluster: ValkeyCluster[Any],
178+
valkey_cluster: ValkeyCluster[Any],
179179
node: ClusterNode | None = None,
180180
host: str | None = None,
181181
port: int | None = None,
@@ -186,7 +186,7 @@ class ClusterPubSub(PubSub):
186186
) -> None: ...
187187
def get_pubsub_node(self) -> ClusterNode | None: ...
188188
def execute_command(self, *args, **kwargs) -> None: ...
189-
def get_redis_connection(self) -> Valkey[Any] | None: ...
189+
def get_valkey_connection(self) -> Valkey[Any] | None: ...
190190

191191
class ClusterPipeline(ValkeyCluster[_StrType]):
192192
command_stack: list[Incomplete]

valkey/commands/graph/__init__.pyi

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,22 @@ class Graph(GraphCommands):
2424
def labels(self): ...
2525
def relationship_types(self): ...
2626
def property_keys(self): ...
27+
28+
29+
class AsyncGraph(GraphCommands):
30+
NAME: Any
31+
client: Any
32+
execute_command: Any
33+
nodes: Any
34+
edges: Any
35+
version: int
36+
def __init__(self, client, name=...) -> None: ...
37+
async def get_label(self, idx): ...
38+
async def get_relation(self, idx): ...
39+
async def get_property(self, idx): ...
40+
async def add_node(self, node) -> None: ...
41+
async def add_edge(self, edge) -> None: ...
42+
async def call_procedure(self, procedure, *args, read_only: bool = False, **kwagrs): ...
43+
async def labels(self): ...
44+
async def relationship_types(self): ...
45+
async def property_keys(self): ...

valkey/commands/graph/execution_plan.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ def _create_operation(args):
166166
args.pop(0)
167167
if len(args) > 0 and "Records produced" in args[-1]:
168168
records_produced = int(
169-
re.search("Records produced: (\\d+)", args[-1]).group(1)
169+
re.search("Records produced: (\\d+)", args[-1]).group(1) # type: ignore[union-attr]
170170
)
171171
execution_time = float(
172-
re.search("Execution time: (\\d+.\\d+) ms", args[-1]).group(1)
172+
re.search("Execution time: (\\d+.\\d+) ms", args[-1]).group(1) # type: ignore[union-attr]
173173
)
174174
profile_stats = ProfileStats(records_produced, execution_time)
175175
args.pop(-1)
@@ -186,15 +186,15 @@ def _create_operation(args):
186186
# set the current operation and move next
187187
child = _create_operation(current_op.split("|"))
188188
if current:
189-
current = stack.pop()
189+
current = stack.pop() # type: ignore[unreachable]
190190
current.append_child(child)
191191
current = child
192192
i += 1
193193
elif op_level == level + 1:
194194
# if the operation is child of the current operation
195195
# add it as child and set as current operation
196196
child = _create_operation(current_op.split("|"))
197-
current.append_child(child)
197+
current.append_child(child) # type: ignore[union-attr]
198198
stack.append(current)
199199
current = child
200200
level += 1

valkey/commands/search/__init__.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,21 @@ class Search(SearchCommands):
2020
def commit(self): ...
2121

2222
def __init__(self, client, index_name: str = "idx") -> None: ...
23+
24+
class AsyncSearch(SearchCommands):
25+
class BatchIndexer:
26+
def __init__(self, client, chunk_size: int = 1000) -> None: ...
27+
async def add_document(
28+
self,
29+
doc_id,
30+
nosave: bool = False,
31+
score: float = 1.0,
32+
payload: Incomplete | None = None,
33+
replace: bool = False,
34+
partial: bool = False,
35+
no_create: bool = False,
36+
**fields,
37+
): ...
38+
async def commit(self): ...
39+
40+
def __init__(self, client, index_name: str = "idx") -> None: ...

valkey/commands/search/aggregation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Reducer:
2222
See the `valkeyearch.reducers` module for the actual reducers.
2323
"""
2424

25-
NAME = None
25+
NAME: Union[str, None] = None
2626

2727
def __init__(self, *args: List[str]) -> None:
2828
self._args = args

valkey/commands/search/aggregation.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, ClassVar, Literal
1+
from typing import Any, ClassVar, Literal, Union
22

33
FIELDNAME: Any
44

@@ -9,7 +9,7 @@ class Limit:
99
def build_args(self): ...
1010

1111
class Reducer:
12-
NAME: ClassVar[None]
12+
NAME: ClassVar[Union[str, None]]
1313
def __init__(self, *args) -> None: ...
1414
def alias(self, alias): ...
1515
@property

valkey/commands/search/field.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List
1+
from typing import List, Union
22

33
from valkey import DataError
44

@@ -18,10 +18,10 @@ class Field:
1818
def __init__(
1919
self,
2020
name: str,
21-
args: List[str] = None,
21+
args: Union[List[str], None] = None,
2222
sortable: bool = False,
2323
no_index: bool = False,
24-
as_name: str = None,
24+
as_name: Union[str, None] = None,
2525
):
2626
if args is None:
2727
args = []
@@ -63,11 +63,11 @@ def __init__(
6363
name: str,
6464
weight: float = 1.0,
6565
no_stem: bool = False,
66-
phonetic_matcher: str = None,
66+
phonetic_matcher: Union[str, None] = None,
6767
withsuffixtrie: bool = False,
6868
**kwargs,
6969
):
70-
Field.__init__(self, name, args=[Field.TEXT, Field.WEIGHT, weight], **kwargs)
70+
Field.__init__(self, name, args=[Field.TEXT, Field.WEIGHT, weight], **kwargs) # type: ignore[list-item]
7171

7272
if no_stem:
7373
Field.append_arg(self, self.NOSTEM)
@@ -180,5 +180,5 @@ def __init__(self, name: str, algorithm: str, attributes: dict, **kwargs):
180180
attr_li.extend([key, value])
181181

182182
Field.__init__(
183-
self, name, args=[Field.VECTOR, algorithm, len(attr_li), *attr_li], **kwargs
183+
self, name, args=[Field.VECTOR, algorithm, len(attr_li), *attr_li], **kwargs # type: ignore[list-item]
184184
)

valkey/commands/search/querystring.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from typing import Dict, List
2+
3+
14
def tags(*t):
25
"""
36
Indicate that the values should be matched to a tag field
@@ -182,7 +185,7 @@ def __init__(self, *children, **kwparams):
182185

183186
self.params = []
184187

185-
kvparams = {}
188+
kvparams: Dict[str, List[Value]] = {}
186189
for k, v in kwparams.items():
187190
curvals = kvparams.setdefault(k, [])
188191
if isinstance(v, (str, int, float)):

valkey/exceptions.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class DataError(ValkeyError): ...
1010
class PubSubError(ValkeyError): ...
1111
class WatchError(ValkeyError): ...
1212
class NoScriptError(ResponseError): ...
13+
class OutOfMemoryError(ResponseError): ...
1314
class ExecAbortError(ResponseError): ...
1415
class ReadOnlyError(ResponseError): ...
1516
class NoPermissionError(ResponseError): ...

valkey/retry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
T = TypeVar("T")
88

99
if TYPE_CHECKING:
10-
from redis.backoff import AbstractBackoff
10+
from valkey.backoff import AbstractBackoff
1111

1212

1313
class Retry:

0 commit comments

Comments
 (0)