coredis 4.24.0__py3-none-any.whl → 5.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of coredis might be problematic. Click here for more details.

Files changed (78) hide show
  1. coredis/__init__.py +1 -3
  2. coredis/_packer.py +10 -10
  3. coredis/_protocols.py +19 -51
  4. coredis/_py_311_typing.py +20 -0
  5. coredis/_py_312_typing.py +17 -0
  6. coredis/_utils.py +49 -55
  7. coredis/_version.py +3 -3
  8. coredis/cache.py +57 -82
  9. coredis/client/__init__.py +1 -2
  10. coredis/client/basic.py +129 -56
  11. coredis/client/cluster.py +147 -70
  12. coredis/commands/__init__.py +27 -7
  13. coredis/commands/_key_spec.py +11 -10
  14. coredis/commands/_utils.py +1 -1
  15. coredis/commands/_validators.py +30 -20
  16. coredis/commands/_wrappers.py +19 -99
  17. coredis/commands/bitfield.py +10 -2
  18. coredis/commands/constants.py +20 -3
  19. coredis/commands/core.py +1674 -1251
  20. coredis/commands/function.py +21 -19
  21. coredis/commands/monitor.py +0 -71
  22. coredis/commands/pubsub.py +7 -142
  23. coredis/commands/request.py +108 -0
  24. coredis/commands/script.py +21 -22
  25. coredis/commands/sentinel.py +60 -49
  26. coredis/connection.py +14 -15
  27. coredis/exceptions.py +2 -2
  28. coredis/experimental/__init__.py +0 -4
  29. coredis/globals.py +3 -0
  30. coredis/modules/autocomplete.py +28 -30
  31. coredis/modules/base.py +15 -31
  32. coredis/modules/filters.py +269 -245
  33. coredis/modules/graph.py +61 -62
  34. coredis/modules/json.py +172 -140
  35. coredis/modules/response/_callbacks/autocomplete.py +5 -4
  36. coredis/modules/response/_callbacks/graph.py +34 -29
  37. coredis/modules/response/_callbacks/json.py +5 -3
  38. coredis/modules/response/_callbacks/search.py +49 -53
  39. coredis/modules/response/_callbacks/timeseries.py +18 -30
  40. coredis/modules/response/types.py +1 -5
  41. coredis/modules/search.py +186 -169
  42. coredis/modules/timeseries.py +184 -164
  43. coredis/parser.py +6 -19
  44. coredis/pipeline.py +477 -521
  45. coredis/pool/basic.py +7 -7
  46. coredis/pool/cluster.py +3 -3
  47. coredis/pool/nodemanager.py +10 -3
  48. coredis/response/_callbacks/__init__.py +76 -57
  49. coredis/response/_callbacks/acl.py +0 -3
  50. coredis/response/_callbacks/cluster.py +25 -16
  51. coredis/response/_callbacks/command.py +8 -6
  52. coredis/response/_callbacks/connection.py +4 -3
  53. coredis/response/_callbacks/geo.py +17 -13
  54. coredis/response/_callbacks/hash.py +13 -11
  55. coredis/response/_callbacks/keys.py +9 -5
  56. coredis/response/_callbacks/module.py +2 -3
  57. coredis/response/_callbacks/script.py +6 -8
  58. coredis/response/_callbacks/sentinel.py +21 -17
  59. coredis/response/_callbacks/server.py +36 -14
  60. coredis/response/_callbacks/sets.py +3 -4
  61. coredis/response/_callbacks/sorted_set.py +27 -24
  62. coredis/response/_callbacks/streams.py +22 -13
  63. coredis/response/_callbacks/strings.py +7 -6
  64. coredis/response/_callbacks/vector_sets.py +159 -0
  65. coredis/response/types.py +13 -4
  66. coredis/retry.py +12 -13
  67. coredis/sentinel.py +11 -1
  68. coredis/stream.py +4 -3
  69. coredis/tokens.py +348 -16
  70. coredis/typing.py +432 -81
  71. {coredis-4.24.0.dist-info → coredis-5.0.0.dist-info}/METADATA +4 -9
  72. coredis-5.0.0.dist-info/RECORD +95 -0
  73. coredis/client/keydb.py +0 -336
  74. coredis/pipeline.pyi +0 -2103
  75. coredis-4.24.0.dist-info/RECORD +0 -93
  76. {coredis-4.24.0.dist-info → coredis-5.0.0.dist-info}/WHEEL +0 -0
  77. {coredis-4.24.0.dist-info → coredis-5.0.0.dist-info}/licenses/LICENSE +0 -0
  78. {coredis-4.24.0.dist-info → coredis-5.0.0.dist-info}/top_level.txt +0 -0
coredis/modules/graph.py CHANGED
@@ -5,6 +5,7 @@ from datetime import timedelta
5
5
  from ..commands._utils import normalized_milliseconds
6
6
  from ..commands._wrappers import ClusterCommandConfig
7
7
  from ..commands.constants import CommandGroup, CommandName, NodeFlag
8
+ from ..commands.request import CommandRequest
8
9
  from ..response._callbacks import (
9
10
  ClusterEnsureConsistent,
10
11
  ClusterMergeSets,
@@ -19,9 +20,9 @@ from ..typing import (
19
20
  KeyT,
20
21
  Literal,
21
22
  Parameters,
23
+ RedisValueT,
22
24
  ResponsePrimitive,
23
25
  StringT,
24
- ValueT,
25
26
  )
26
27
  from .base import Module, ModuleGroup, module_command
27
28
  from .response._callbacks.graph import (
@@ -51,12 +52,12 @@ class Graph(ModuleGroup[AnyStr]):
51
52
  version_introduced="1.0.0",
52
53
  group=COMMAND_GROUP,
53
54
  )
54
- async def query(
55
+ def query(
55
56
  self,
56
57
  graph: KeyT,
57
58
  query: StringT,
58
59
  timeout: int | timedelta | None = None,
59
- ) -> GraphQueryResult[AnyStr]:
60
+ ) -> CommandRequest[GraphQueryResult[AnyStr]]:
60
61
  """
61
62
  Executes the given query against a specified graph
62
63
 
@@ -65,17 +66,16 @@ class Graph(ModuleGroup[AnyStr]):
65
66
  :param timeout: The maximum amount of time (milliseconds) to wait for the query to complete
66
67
  :return: The result set of the executed query.
67
68
  """
68
- pieces: CommandArgList = [graph, query]
69
+ command_arguments: CommandArgList = [graph, query]
69
70
 
70
71
  if timeout is not None:
71
- pieces.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
72
+ command_arguments.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
72
73
 
73
- pieces.append(b"--compact")
74
- return await self.execute_module_command(
74
+ command_arguments.append(b"--compact")
75
+ return self.client.create_request(
75
76
  CommandName.GRAPH_QUERY,
76
- *pieces,
77
- callback=QueryCallback[AnyStr](graph),
78
- query=query,
77
+ *command_arguments,
78
+ callback=QueryCallback[AnyStr](graph, query=query),
79
79
  )
80
80
 
81
81
  @module_command(
@@ -84,12 +84,12 @@ class Graph(ModuleGroup[AnyStr]):
84
84
  version_introduced="2.2.8",
85
85
  group=COMMAND_GROUP,
86
86
  )
87
- async def ro_query(
87
+ def ro_query(
88
88
  self,
89
89
  graph: KeyT,
90
90
  query: StringT,
91
91
  timeout: int | timedelta | None = None,
92
- ) -> GraphQueryResult[AnyStr]:
92
+ ) -> CommandRequest[GraphQueryResult[AnyStr]]:
93
93
  """
94
94
  Executes a given read only query against a specified graph
95
95
 
@@ -98,16 +98,15 @@ class Graph(ModuleGroup[AnyStr]):
98
98
  :param timeout: The maximum amount of time (milliseconds) to wait for the query to complete.
99
99
  :return: The result set for the read-only query or an error if a write query was given.
100
100
  """
101
- pieces: CommandArgList = [graph, query]
101
+ command_arguments: CommandArgList = [graph, query]
102
102
  if timeout is not None:
103
- pieces.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
104
- pieces.append(b"--compact")
103
+ command_arguments.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
104
+ command_arguments.append(b"--compact")
105
105
 
106
- return await self.execute_module_command(
106
+ return self.client.create_request(
107
107
  CommandName.GRAPH_RO_QUERY,
108
- *pieces,
109
- callback=QueryCallback[AnyStr](graph),
110
- query=query,
108
+ *command_arguments,
109
+ callback=QueryCallback[AnyStr](graph, query=query),
111
110
  )
112
111
 
113
112
  @module_command(
@@ -116,7 +115,7 @@ class Graph(ModuleGroup[AnyStr]):
116
115
  version_introduced="1.0.0",
117
116
  group=COMMAND_GROUP,
118
117
  )
119
- async def delete(self, graph: KeyT) -> bool:
118
+ def delete(self, graph: KeyT) -> CommandRequest[bool]:
120
119
  """
121
120
  Completely removes the graph and all of its entities
122
121
 
@@ -125,7 +124,7 @@ class Graph(ModuleGroup[AnyStr]):
125
124
  :param graph: The name of the graph to be deleted.
126
125
  """
127
126
 
128
- return await self.execute_module_command(
127
+ return self.client.create_request(
129
128
  CommandName.GRAPH_DELETE,
130
129
  graph,
131
130
  callback=SimpleStringCallback(prefix_match=True, ok_values={"Graph removed"}),
@@ -137,7 +136,7 @@ class Graph(ModuleGroup[AnyStr]):
137
136
  version_introduced="2.0.0",
138
137
  group=COMMAND_GROUP,
139
138
  )
140
- async def explain(self, graph: KeyT, query: StringT) -> list[AnyStr]:
139
+ def explain(self, graph: KeyT, query: StringT) -> CommandRequest[list[AnyStr]]:
141
140
  """
142
141
 
143
142
  Constructs a query execution plan for the given :paramref:`graph` and
@@ -149,7 +148,7 @@ class Graph(ModuleGroup[AnyStr]):
149
148
  :return: A list of strings representing the query execution plan.
150
149
  """
151
150
 
152
- return await self.execute_module_command(
151
+ return self.client.create_request(
153
152
  CommandName.GRAPH_EXPLAIN, graph, query, callback=ListCallback[AnyStr]()
154
153
  )
155
154
 
@@ -159,12 +158,12 @@ class Graph(ModuleGroup[AnyStr]):
159
158
  version_introduced="2.0.0",
160
159
  group=COMMAND_GROUP,
161
160
  )
162
- async def profile(
161
+ def profile(
163
162
  self,
164
163
  graph: KeyT,
165
164
  query: StringT,
166
165
  timeout: int | timedelta | None = None,
167
- ) -> list[AnyStr]:
166
+ ) -> CommandRequest[list[AnyStr]]:
168
167
  """
169
168
  Executes a query and returns an execution plan augmented with metrics for each
170
169
  operation's execution
@@ -175,11 +174,13 @@ class Graph(ModuleGroup[AnyStr]):
175
174
  :return: A string representation of a query execution plan, with details on results produced
176
175
  by and time spent in each operation.
177
176
  """
178
- pieces: CommandArgList = [graph, query]
177
+ command_arguments: CommandArgList = [graph, query]
179
178
  if timeout is not None:
180
- pieces.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
181
- return await self.execute_module_command(
182
- CommandName.GRAPH_PROFILE, *pieces, callback=ListCallback[AnyStr]()
179
+ command_arguments.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
180
+ return self.client.create_request(
181
+ CommandName.GRAPH_PROFILE,
182
+ *command_arguments,
183
+ callback=ListCallback[AnyStr](),
183
184
  )
184
185
 
185
186
  @module_command(
@@ -189,9 +190,9 @@ class Graph(ModuleGroup[AnyStr]):
189
190
  arguments={"reset": {"version_introduced": "2.12.0"}},
190
191
  group=COMMAND_GROUP,
191
192
  )
192
- async def slowlog(
193
+ def slowlog(
193
194
  self, graph: KeyT, reset: bool = False
194
- ) -> tuple[GraphSlowLogInfo, ...] | bool:
195
+ ) -> CommandRequest[tuple[GraphSlowLogInfo, ...]] | CommandRequest[bool]:
195
196
  """
196
197
  Returns a list containing up to 10 of the slowest queries issued against the given graph
197
198
 
@@ -199,18 +200,18 @@ class Graph(ModuleGroup[AnyStr]):
199
200
  :param reset: If ``True``, the slowlog will be reset
200
201
  :return: The slowlog for the given graph or ``True`` if the slowlog was reset
201
202
  """
202
- pieces: CommandArgList = [graph]
203
+ command_arguments: CommandArgList = [graph]
203
204
  if reset:
204
- pieces.append(PureToken.RESET)
205
- return await self.execute_module_command(
205
+ command_arguments.append(PureToken.RESET)
206
+ return self.client.create_request(
206
207
  CommandName.GRAPH_SLOWLOG,
207
- *pieces,
208
+ *command_arguments,
208
209
  callback=SimpleStringCallback(),
209
210
  )
210
211
  else:
211
- return await self.execute_module_command(
212
+ return self.client.create_request(
212
213
  CommandName.GRAPH_SLOWLOG,
213
- *pieces,
214
+ *command_arguments,
214
215
  callback=GraphSlowLogCallback(),
215
216
  )
216
217
 
@@ -223,9 +224,9 @@ class Graph(ModuleGroup[AnyStr]):
223
224
  route=NodeFlag.RANDOM,
224
225
  ),
225
226
  )
226
- async def config_get(
227
+ def config_get(
227
228
  self, name: StringT
228
- ) -> dict[AnyStr, ResponsePrimitive] | ResponsePrimitive:
229
+ ) -> CommandRequest[dict[AnyStr, ResponsePrimitive] | ResponsePrimitive]:
229
230
  """
230
231
  Retrieves a RedisGraph configuration
231
232
 
@@ -233,7 +234,7 @@ class Graph(ModuleGroup[AnyStr]):
233
234
  :return: The value of the configuration parameter. If :paramref:`name`
234
235
  is ``*``, a mapping of all configuration parameters to their values
235
236
  """
236
- return await self.execute_module_command(
237
+ return self.client.create_request(
237
238
  CommandName.GRAPH_CONFIG_GET,
238
239
  name,
239
240
  callback=ConfigGetCallback[AnyStr](),
@@ -249,7 +250,7 @@ class Graph(ModuleGroup[AnyStr]):
249
250
  combine=ClusterEnsureConsistent[AnyStr](),
250
251
  ),
251
252
  )
252
- async def config_set(self, name: StringT, value: ValueT) -> bool:
253
+ def config_set(self, name: StringT, value: RedisValueT) -> CommandRequest[bool]:
253
254
  """
254
255
  Updates a RedisGraph configuration
255
256
 
@@ -257,7 +258,7 @@ class Graph(ModuleGroup[AnyStr]):
257
258
  :param value: The value to set the configuration parameter to.
258
259
  :return: True if the configuration parameter was set successfully, False otherwise.
259
260
  """
260
- return await self.execute_module_command(
261
+ return self.client.create_request(
261
262
  CommandName.GRAPH_CONFIG_SET, name, value, callback=SimpleStringCallback()
262
263
  )
263
264
 
@@ -271,16 +272,14 @@ class Graph(ModuleGroup[AnyStr]):
271
272
  combine=ClusterMergeSets[AnyStr](),
272
273
  ),
273
274
  )
274
- async def list(self) -> set[AnyStr]:
275
+ def list(self) -> CommandRequest[set[AnyStr]]:
275
276
  """
276
277
  Lists all graph keys in the keyspace
277
278
 
278
279
  :return: A list of graph keys in the keyspace.
279
280
  """
280
281
 
281
- return await self.execute_module_command(
282
- CommandName.GRAPH_LIST, callback=SetCallback[AnyStr]()
283
- )
282
+ return self.client.create_request(CommandName.GRAPH_LIST, callback=SetCallback[AnyStr]())
284
283
 
285
284
  @module_command(
286
285
  CommandName.GRAPH_CONSTRAINT_DROP,
@@ -288,14 +287,14 @@ class Graph(ModuleGroup[AnyStr]):
288
287
  version_introduced="2.12.0",
289
288
  group=COMMAND_GROUP,
290
289
  )
291
- async def constraint_drop(
290
+ def constraint_drop(
292
291
  self,
293
292
  graph: KeyT,
294
293
  type: Literal[PureToken.MANDATORY, PureToken.UNIQUE],
295
294
  node: StringT | None = None,
296
295
  relationship: StringT | None = None,
297
296
  properties: Parameters[StringT] | None = None,
298
- ) -> bool:
297
+ ) -> CommandRequest[bool]:
299
298
  """
300
299
  Deletes a constraint from specified graph
301
300
 
@@ -307,18 +306,18 @@ class Graph(ModuleGroup[AnyStr]):
307
306
 
308
307
  :return: True if the constraint was successfully dropped, False otherwise.
309
308
  """
310
- pieces: CommandArgList = [graph, type]
309
+ command_arguments: CommandArgList = [graph, type]
311
310
  if node is not None:
312
- pieces.extend([PrefixToken.NODE, node])
311
+ command_arguments.extend([PrefixToken.NODE, node])
313
312
  if relationship is not None:
314
- pieces.extend([PrefixToken.RELATIONSHIP, relationship])
313
+ command_arguments.extend([PrefixToken.RELATIONSHIP, relationship])
315
314
  if properties:
316
315
  _props: list[StringT] = list(properties)
317
- pieces.extend([PrefixToken.PROPERTIES, len(_props), *_props])
316
+ command_arguments.extend([PrefixToken.PROPERTIES, len(_props), *_props])
318
317
 
319
- return await self.execute_module_command(
318
+ return self.client.create_request(
320
319
  CommandName.GRAPH_CONSTRAINT_DROP,
321
- *pieces,
320
+ *command_arguments,
322
321
  callback=SimpleStringCallback(),
323
322
  )
324
323
 
@@ -328,14 +327,14 @@ class Graph(ModuleGroup[AnyStr]):
328
327
  version_introduced="2.12.0",
329
328
  group=COMMAND_GROUP,
330
329
  )
331
- async def constraint_create(
330
+ def constraint_create(
332
331
  self,
333
332
  graph: KeyT,
334
333
  type: Literal[PureToken.MANDATORY, PureToken.UNIQUE],
335
334
  node: StringT | None = None,
336
335
  relationship: StringT | None = None,
337
336
  properties: Parameters[StringT] | None = None,
338
- ) -> bool:
337
+ ) -> CommandRequest[bool]:
339
338
  """
340
339
  Creates a constraint on specified graph
341
340
 
@@ -347,17 +346,17 @@ class Graph(ModuleGroup[AnyStr]):
347
346
  :param properties: The properties to apply the constraint to.
348
347
  :return: True if the constraint was created successfully, False otherwise.
349
348
  """
350
- pieces: CommandArgList = [graph, type]
349
+ command_arguments: CommandArgList = [graph, type]
351
350
 
352
351
  if node is not None:
353
- pieces.extend([PrefixToken.NODE, node])
352
+ command_arguments.extend([PrefixToken.NODE, node])
354
353
  if relationship is not None:
355
- pieces.extend([PrefixToken.RELATIONSHIP, relationship])
354
+ command_arguments.extend([PrefixToken.RELATIONSHIP, relationship])
356
355
  if properties:
357
356
  _props: list[StringT] = list(properties)
358
- pieces.extend([PrefixToken.PROPERTIES, len(_props), *_props])
359
- return await self.execute_module_command(
357
+ command_arguments.extend([PrefixToken.PROPERTIES, len(_props), *_props])
358
+ return self.client.create_request(
360
359
  CommandName.GRAPH_CONSTRAINT_CREATE,
361
- *pieces,
360
+ *command_arguments,
362
361
  callback=SimpleStringCallback(ok_values={"PENDING"}),
363
362
  )