valkey-glide 1.2.0rc14__cp311-cp311-macosx_11_0_arm64.whl → 2.2.3__cp311-cp311-macosx_11_0_arm64.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.
Files changed (47) hide show
  1. glide/__init__.py +169 -104
  2. glide/async_commands/cluster_commands.py +367 -172
  3. glide/async_commands/core.py +1808 -1026
  4. glide/async_commands/{server_modules/ft.py → ft.py} +91 -21
  5. glide/async_commands/{server_modules/glide_json.py → glide_json.py} +161 -146
  6. glide/async_commands/standalone_commands.py +204 -136
  7. glide/glide.cpython-311-darwin.so +0 -0
  8. glide/glide.pyi +26 -1
  9. glide/glide_client.py +355 -136
  10. glide/logger.py +34 -22
  11. glide/opentelemetry.py +185 -0
  12. glide_shared/__init__.py +330 -0
  13. glide_shared/commands/__init__.py +0 -0
  14. glide/async_commands/transaction.py → glide_shared/commands/batch.py +1845 -1059
  15. glide_shared/commands/batch_options.py +261 -0
  16. {glide/async_commands → glide_shared/commands}/bitmap.py +96 -86
  17. {glide/async_commands → glide_shared/commands}/command_args.py +7 -6
  18. glide_shared/commands/core_options.py +407 -0
  19. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_aggregate_options.py +18 -11
  20. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_create_options.py +27 -13
  21. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_profile_options.py +16 -11
  22. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_search_options.py +17 -9
  23. glide_shared/commands/server_modules/json_batch.py +820 -0
  24. glide_shared/commands/server_modules/json_options.py +93 -0
  25. {glide/async_commands → glide_shared/commands}/sorted_set.py +42 -32
  26. {glide/async_commands → glide_shared/commands}/stream.py +95 -88
  27. glide_shared/config.py +975 -0
  28. {glide → glide_shared}/constants.py +11 -7
  29. {glide → glide_shared}/exceptions.py +27 -1
  30. glide_shared/protobuf/command_request_pb2.py +56 -0
  31. glide_shared/protobuf/connection_request_pb2.py +56 -0
  32. {glide → glide_shared}/protobuf/response_pb2.py +6 -6
  33. {glide → glide_shared}/protobuf_codec.py +7 -6
  34. glide_shared/routes.py +161 -0
  35. valkey_glide-2.2.3.dist-info/METADATA +211 -0
  36. valkey_glide-2.2.3.dist-info/RECORD +40 -0
  37. {valkey_glide-1.2.0rc14.dist-info → valkey_glide-2.2.3.dist-info}/WHEEL +1 -1
  38. glide/config.py +0 -521
  39. glide/protobuf/command_request_pb2.py +0 -54
  40. glide/protobuf/command_request_pb2.pyi +0 -1161
  41. glide/protobuf/connection_request_pb2.py +0 -52
  42. glide/protobuf/connection_request_pb2.pyi +0 -287
  43. glide/protobuf/response_pb2.pyi +0 -101
  44. glide/routes.py +0 -114
  45. valkey_glide-1.2.0rc14.dist-info/METADATA +0 -122
  46. valkey_glide-1.2.0rc14.dist-info/RECORD +0 -36
  47. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +0 -0
@@ -1,114 +1,38 @@
1
1
  # Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
2
2
  """Glide module for `JSON` commands.
3
3
 
4
- Examples:
5
-
6
- >>> from glide import glide_json
7
- >>> import json
8
- >>> value = {'a': 1.0, 'b': 2}
9
- >>> json_str = json.dumps(value) # Convert Python dictionary to JSON string using json.dumps()
10
- >>> await json.set(client, "doc", "$", json_str)
11
- 'OK' # Indicates successful setting of the value at path '$' in the key stored at `doc`.
12
- >>> json_get = await glide_json.get(client, "doc", "$") # Returns the value at path '$' in the JSON document stored at `doc` as JSON string.
13
- >>> print(json_get)
14
- b"[{\"a\":1.0,\"b\":2}]"
15
- >>> json.loads(str(json_get))
16
- [{"a": 1.0, "b" :2}] # JSON object retrieved from the key `doc` using json.loads()
17
- """
4
+ Examples:
5
+
6
+ >>> from glide import glide_json
7
+ >>> import json
8
+ >>> value = {'a': 1.0, 'b': 2}
9
+ >>> json_str = json.dumps(value) # Convert Python dictionary to JSON string using json.dumps()
10
+ >>> await glide_json.set(client, "doc", "$", json_str)
11
+ 'OK' # Indicates successful setting of the value at path '$' in the key stored at `doc`.
12
+ >>> json_get = await glide_json.get(client, "doc", "$") # Returns the value at path '$' in the JSON document stored at
13
+ # `doc` as JSON string.
14
+ >>> print(json_get)
15
+ b"[{\"a\":1.0,\"b\":2}]"
16
+ >>> json.loads(str(json_get))
17
+ [{"a": 1.0, "b" :2}] # JSON object retrieved from the key `doc` using json.loads()
18
+
19
+ """
18
20
  from typing import List, Optional, Union, cast
19
21
 
20
- from glide.async_commands.core import ConditionalChange
21
- from glide.constants import TOK, TEncodable, TJsonResponse, TJsonUniversalResponse
22
- from glide.glide_client import TGlideClient
23
- from glide.protobuf.command_request_pb2 import RequestType
24
-
25
-
26
- class JsonGetOptions:
27
- """
28
- Represents options for formatting JSON data, to be used in the [JSON.GET](https://valkey.io/commands/json.get/) command.
29
-
30
- Args:
31
- indent (Optional[str]): Sets an indentation string for nested levels. Defaults to None.
32
- newline (Optional[str]): Sets a string that's printed at the end of each line. Defaults to None.
33
- space (Optional[str]): Sets a string that's put between a key and a value. Defaults to None.
34
- """
35
-
36
- def __init__(
37
- self,
38
- indent: Optional[str] = None,
39
- newline: Optional[str] = None,
40
- space: Optional[str] = None,
41
- ):
42
- self.indent = indent
43
- self.new_line = newline
44
- self.space = space
45
-
46
- def get_options(self) -> List[str]:
47
- args = []
48
- if self.indent:
49
- args.extend(["INDENT", self.indent])
50
- if self.new_line:
51
- args.extend(["NEWLINE", self.new_line])
52
- if self.space:
53
- args.extend(["SPACE", self.space])
54
- return args
55
-
56
-
57
- class JsonArrIndexOptions:
58
- """
59
- Options for the `JSON.ARRINDEX` command.
60
-
61
- Args:
62
- start (int): The inclusive start index from which the search begins. Defaults to None.
63
- end (Optional[int]): The exclusive end index where the search stops. Defaults to None.
64
-
65
- Note:
66
- - If `start` is greater than `end`, the command returns `-1` to indicate that the value was not found.
67
- - Indices that exceed the array bounds are automatically adjusted to the nearest valid position.
68
- """
69
-
70
- def __init__(self, start: int, end: Optional[int] = None):
71
- self.start = start
72
- self.end = end
73
-
74
- def to_args(self) -> List[str]:
75
- """
76
- Get the options as a list of arguments for the JSON.ARRINDEX command.
77
-
78
- Returns:
79
- List[str]: A list containing the start and end indices if specified.
80
- """
81
- args = [str(self.start)]
82
- if self.end is not None:
83
- args.append(str(self.end))
84
- return args
85
-
86
-
87
- class JsonArrPopOptions:
88
- """
89
- Options for the JSON.ARRPOP command.
90
-
91
- Args:
92
- path (TEncodable): The path within the JSON document.
93
- index (Optional[int]): The index of the element to pop. If not specified, will pop the last element.
94
- Out of boundary indexes are rounded to their respective array boundaries. Defaults to None.
95
- """
96
-
97
- def __init__(self, path: TEncodable, index: Optional[int] = None):
98
- self.path = path
99
- self.index = index
22
+ from glide_shared.commands.core_options import ConditionalChange
23
+ from glide_shared.commands.server_modules.json_options import (
24
+ JsonArrIndexOptions,
25
+ JsonArrPopOptions,
26
+ JsonGetOptions,
27
+ )
28
+ from glide_shared.constants import (
29
+ TOK,
30
+ TEncodable,
31
+ TJsonResponse,
32
+ TJsonUniversalResponse,
33
+ )
100
34
 
101
- def to_args(self) -> List[TEncodable]:
102
- """
103
- Get the options as a list of arguments for the `JSON.ARRPOP` command.
104
-
105
- Returns:
106
- List[TEncodable]: A list containing the path and, if specified, the index.
107
- """
108
- args = [self.path]
109
- if self.index is not None:
110
- args.append(str(self.index))
111
- return args
35
+ from ..glide_client import TGlideClient
112
36
 
113
37
 
114
38
  async def set(
@@ -125,7 +49,8 @@ async def set(
125
49
  client (TGlideClient): The client to execute the command.
126
50
  key (TEncodable): The key of the JSON document.
127
51
  path (TEncodable): Represents the path within the JSON document where the value will be set.
128
- The key will be modified only if `value` is added as the last child in the specified `path`, or if the specified `path` acts as the parent of a new child being added.
52
+ The key will be modified only if `value` is added as the last child in the specified `path`, or if the specified
53
+ `path` acts as the parent of a new child being added.
129
54
  value (TEncodable): The value to set at the specific path, in JSON formatted bytes or str.
130
55
  set_condition (Optional[ConditionalChange]): Set the value only if the given condition is met (within the key or path).
131
56
  Equivalent to [`XX` | `NX`] in the RESP API. Defaults to None.
@@ -161,8 +86,10 @@ async def get(
161
86
  Args:
162
87
  client (TGlideClient): The client to execute the command.
163
88
  key (TEncodable): The key of the JSON document.
164
- paths (Optional[Union[TEncodable, List[TEncodable]]]): The path or list of paths within the JSON document. Default to None.
165
- options (Optional[JsonGetOptions]): Options for formatting the byte representation of the JSON data. See `JsonGetOptions`.
89
+ paths (Optional[Union[TEncodable, List[TEncodable]]]): The path or list of paths within the JSON document.
90
+ Default to None.
91
+ options (Optional[JsonGetOptions]): Options for formatting the byte representation of the JSON data.
92
+ See `JsonGetOptions`.
166
93
 
167
94
  Returns:
168
95
  TJsonResponse[Optional[bytes]]:
@@ -176,8 +103,10 @@ async def get(
176
103
  If `path` doesn't exist, an error is raised.
177
104
  If `key` doesn't exist, returns None.
178
105
  If multiple paths are given:
179
- Returns a stringified JSON object in bytes, in which each path is a key, and it's corresponding value, is the value as if the path was executed in the command as a single path.
180
- In case of multiple paths, and `paths` are a mix of both JSONPath and legacy path, the command behaves as if all are JSONPath paths.
106
+ Returns a stringified JSON object in bytes, in which each path is a key, and it's corresponding value, is the
107
+ value as if the path was executed in the command as a single path.
108
+ In case of multiple paths, and `paths` are a mix of both JSONPath and legacy path, the command behaves as if all are
109
+ JSONPath paths.
181
110
  For more information about the returned type, see `TJsonResponse`.
182
111
 
183
112
  Examples:
@@ -189,9 +118,12 @@ async def get(
189
118
  >>> await glide_json.get(client, "doc", "$")
190
119
  b"[{\"a\":1.0,\"b\":2}]" # Returns the value at path '$' in the JSON document stored at `doc`.
191
120
  >>> await glide_json.get(client, "doc", ["$.a", "$.b"], JsonGetOptions(indent=" ", newline="\n", space=" "))
192
- b"{\n \"$.a\": [\n 1.0\n ],\n \"$.b\": [\n 2\n ]\n}" # Returns the values at paths '$.a' and '$.b' in the JSON document stored at `doc`, with specified formatting options.
121
+ b"{\n \"$.a\": [\n 1.0\n ],\n \"$.b\": [\n 2\n ]\n}" # Returns the values at paths '$.a' and '$.b' in the JSON
122
+ # document stored at `doc`, with specified
123
+ # formatting options.
193
124
  >>> await glide_json.get(client, "doc", "$.non_existing_path")
194
- b"[]" # Returns an empty array since the path '$.non_existing_path' does not exist in the JSON document stored at `doc`.
125
+ b"[]" # Returns an empty array since the path '$.non_existing_path' does not exist in the JSON document
126
+ # stored at `doc`.
195
127
  """
196
128
  args = ["JSON.GET", key]
197
129
  if options:
@@ -223,7 +155,8 @@ async def arrappend(
223
155
  Returns:
224
156
  TJsonResponse[int]:
225
157
  For JSONPath (`path` starts with `$`):
226
- Returns a list of integer replies for every possible path, indicating the new length of the array after appending `values`,
158
+ Returns a list of integer replies for every possible path, indicating the new length of the array after
159
+ appending `values`,
227
160
  or None for JSON values matching the path that are not an array.
228
161
  If `path` doesn't exist, an empty array will be returned.
229
162
  For legacy path (`path` doesn't start with `$`):
@@ -257,12 +190,14 @@ async def arrindex(
257
190
  options: Optional[JsonArrIndexOptions] = None,
258
191
  ) -> TJsonResponse[int]:
259
192
  """
260
- Searches for the first occurrence of a scalar JSON value (i.e., a value that is neither an object nor an array) within arrays at the specified `path` in the JSON document stored at `key`.
193
+ Searches for the first occurrence of a scalar JSON value (i.e., a value that is neither an object nor an array) within
194
+ arrays at the specified `path` in the JSON document stored at `key`.
261
195
 
262
196
  If specified, `options.start` and `options.end` define an inclusive-to-exclusive search range within the array.
263
197
  (Where `options.start` is inclusive and `options.end` is exclusive).
264
198
 
265
- Out-of-range indices adjust to the nearest valid position, and negative values count from the end (e.g., `-1` is the last element, `-2` the second last).
199
+ Out-of-range indices adjust to the nearest valid position, and negative values count from the end (e.g., `-1` is the last
200
+ element, `-2` the second last).
266
201
 
267
202
  Setting `options.end` to `0` behaves like `-1`, extending the range to the array's end (inclusive).
268
203
 
@@ -273,18 +208,21 @@ async def arrindex(
273
208
  key (TEncodable): The key of the JSON document.
274
209
  path (TEncodable): The path within the JSON document.
275
210
  value (TEncodable): The value to search for within the arrays.
276
- options (Optional[JsonArrIndexOptions]): Options specifying an inclusive `start` index and an optional exclusive `end` index for a range-limited search.
211
+ options (Optional[JsonArrIndexOptions]): Options specifying an inclusive `start` index and an optional exclusive `end`
212
+ index for a range-limited search.
277
213
  Defaults to the full array if not provided. See `JsonArrIndexOptions`.
278
214
 
279
215
  Returns:
280
216
  Optional[TJsonResponse[int]]:
281
217
  For JSONPath (`path` starts with `$`):
282
- Returns an array of integers for every possible path, indicating of the first occurrence of `value` within the array,
218
+ Returns an array of integers for every possible path, indicating of the first occurrence of `value`
219
+ within the array,
283
220
  or None for JSON values matching the path that are not an array.
284
221
  A returned value of `-1` indicates that the value was not found in that particular array.
285
222
  If `path` does not exist, an empty array will be returned.
286
223
  For legacy path (`path` doesn't start with `$`):
287
- Returns an integer representing the index of the first occurrence of `value` within the array at the specified path.
224
+ Returns an integer representing the index of the first occurrence of `value` within the array at the
225
+ specified path.
288
226
  A returned value of `-1` indicates that the value was not found in that particular array.
289
227
  If multiple paths match, the index of the value from the first matching array is returned.
290
228
  If the JSON value at the `path` is not an array or if `path` does not exist, an error is raised.
@@ -330,7 +268,8 @@ async def arrinsert(
330
268
  values: List[TEncodable],
331
269
  ) -> TJsonResponse[int]:
332
270
  """
333
- Inserts one or more values into the array at the specified `path` within the JSON document stored at `key`, before the given `index`.
271
+ Inserts one or more values into the array at the specified `path` within the JSON document stored at `key`,
272
+ before the given `index`.
334
273
 
335
274
  Args:
336
275
  client (TGlideClient): The client to execute the command.
@@ -441,7 +380,8 @@ async def arrpop(
441
380
  Args:
442
381
  client (TGlideClient): The client to execute the command.
443
382
  key (TEncodable): The key of the JSON document.
444
- options (Optional[JsonArrPopOptions]): Options including the path and optional index. See `JsonArrPopOptions`. Default to None.
383
+ options (Optional[JsonArrPopOptions]): Options including the path and optional index. See `JsonArrPopOptions`.
384
+ Default to None.
445
385
  If not specified, attempts to pop the last element from the root value if it's an array.
446
386
  If the root value is not an array, an error will be raised.
447
387
 
@@ -460,7 +400,12 @@ async def arrpop(
460
400
 
461
401
  Examples:
462
402
  >>> from glide import glide_json
463
- >>> await glide_json.set(client, "doc", "$", '{"a": [1, 2, true], "b": {"a": [3, 4, ["value", 3, false], 5], "c": {"a": 42}}}')
403
+ >>> await glide_json.set(
404
+ ... client,
405
+ ... "doc",
406
+ ... "$",
407
+ ... '{"a": [1, 2, true], "b": {"a": [3, 4, ["value", 3, false], 5], "c": {"a": 42}}}'
408
+ ... )
464
409
  b'OK'
465
410
  >>> await glide_json.arrpop(client, "doc", JsonArrPopOptions(path="$.a", index=1))
466
411
  [b'2'] # Pop second element from array at path $.a
@@ -500,7 +445,8 @@ async def arrtrim(
500
445
  end: int,
501
446
  ) -> TJsonResponse[int]:
502
447
  """
503
- Trims an array at the specified `path` within the JSON document stored at `key` so that it becomes a subarray [start, end], both inclusive.
448
+ Trims an array at the specified `path` within the JSON document stored at `key` so that it becomes a subarray [start, end],
449
+ both inclusive.
504
450
  If `start` < 0, it is treated as 0.
505
451
  If `end` >= size (size of the array), it is treated as size-1.
506
452
  If `start` >= size or `start` > `end`, the array is emptied and 0 is returned.
@@ -515,7 +461,8 @@ async def arrtrim(
515
461
  Returns:
516
462
  TJsonResponse[int]:
517
463
  For JSONPath (`path` starts with '$'):
518
- Returns a list of integer replies for every possible path, indicating the new length of the array, or None for JSON values matching the path that are not an array.
464
+ Returns a list of integer replies for every possible path, indicating the new length of the array, or None for
465
+ JSON values matching the path that are not an array.
519
466
  If a value is an empty array, its corresponding return value is 0.
520
467
  If `path` doesn't exist, an empty array will be returned.
521
468
  For legacy path (`path` doesn't starts with `$`):
@@ -565,12 +512,18 @@ async def clear(
565
512
  Returns:
566
513
  int: The number of containers cleared, numeric values zeroed, and booleans toggled to `false`,
567
514
  and string values converted to empty strings.
568
- If `path` doesn't exist, or the value at `path` is already empty (e.g., an empty array, object, or string), 0 is returned.
515
+ If `path` doesn't exist, or the value at `path` is already empty (e.g., an empty array, object, or string),
516
+ 0 is returned.
569
517
  If `key doesn't exist, an error is raised.
570
518
 
571
519
  Examples:
572
520
  >>> from glide import glide_json
573
- >>> await glide_json.set(client, "doc", "$", '{"obj":{"a":1, "b":2}, "arr":[1,2,3], "str": "foo", "bool": true, "int": 42, "float": 3.14, "nullVal": null}')
521
+ >>> await glide_json.set(
522
+ ... client,
523
+ ... "doc",
524
+ ... "$",
525
+ ... '{"obj":{"a":1, "b":2}, "arr":[1,2,3], "str": "foo", "bool": true, "int": 42, "float": 3.14, "nullVal": null}'
526
+ ... )
574
527
  'OK' # JSON document is successfully set.
575
528
  >>> await glide_json.clear(client, "doc", "$.*")
576
529
  6 # 6 values are cleared (arrays/objects/strings/numbers/booleans), but `null` remains as is.
@@ -579,7 +532,18 @@ async def clear(
579
532
  >>> await glide_json.clear(client, "doc", "$.*")
580
533
  0 # No further clearing needed since the containers are already empty and the values are defaults.
581
534
 
582
- >>> await glide_json.set(client, "doc", "$", '{"a": 1, "b": {"a": [5, 6, 7], "b": {"a": true}}, "c": {"a": "value", "b": {"a": 3.5}}, "d": {"a": {"foo": "foo"}}, "nullVal": null}')
535
+ >>> await glide_json.set(
536
+ ... client,
537
+ ... "doc",
538
+ ... "$",
539
+ ... (
540
+ ... '{"a": 1, '
541
+ ... '"b": {"a": [5, 6, 7], "b": {"a": true}}, '
542
+ ... '"c": {"a": "value", "b": {"a": 3.5}}, '
543
+ ... '"d": {"a": {"foo": "foo"}}, '
544
+ ... '"nullVal": null}'
545
+ ... )
546
+ ... )
583
547
  'OK'
584
548
  >>> await glide_json.clear(client, "doc", "b.a[1:3]")
585
549
  2 # 2 elements (`6` and `7`) are cleared.
@@ -608,7 +572,8 @@ async def debug_fields(
608
572
  """
609
573
  Returns the number of fields of the JSON value at the specified `path` within the JSON document stored at `key`.
610
574
  - **Primitive Values**: Each non-container JSON value (e.g., strings, numbers, booleans, and null) counts as one field.
611
- - **Arrays and Objects:**: Each item in an array and each key-value pair in an object is counted as one field. (Each top-level value counts as one field, regardless of it's type.)
575
+ - **Arrays and Objects:**: Each item in an array and each key-value pair in an object is counted as one field.
576
+ (Each top-level value counts as one field, regardless of it's type.)
612
577
  - Their nested values are counted recursively and added to the total.
613
578
  - **Example**: For the JSON `{"a": 1, "b": [2, 3, {"c": 4}]}`, the count would be:
614
579
  - Top-level: 2 fields (`"a"` and `"b"`)
@@ -642,7 +607,22 @@ async def debug_fields(
642
607
  >>> await glide_json.debug_fields(client, "k1", ".")
643
608
  14 # 9 top-level fields + 5 nested address fields
644
609
 
645
- >>> await glide_json.set(client, "k1", "$", '{"firstName":"John","lastName":"Smith","age":27,"weight":135.25,"isAlive":true,"address":{"street":"21 2nd Street","city":"New York","state":"NY","zipcode":"10021-3100"},"phoneNumbers":[{"type":"home","number":"212 555-1234"},{"type":"office","number":"646 555-4567"}],"children":[],"spouse":null}')
610
+ >>> await glide_json.set(
611
+ ... client,
612
+ ... "k1",
613
+ ... "$",
614
+ ... (
615
+ ... '{"firstName":"John", '
616
+ ... '"lastName":"Smith", '
617
+ ... '"age":27, '
618
+ ... '"weight":135.25, '
619
+ ... '"isAlive":true, '
620
+ ... '"address":{"street":"21 2nd Street","city":"New York","state":"NY","zipcode":"10021-3100"}, '
621
+ ... '"phoneNumbers":[{"type":"home","number":"212 555-1234"},{"type":"office","number":"646 555-4567"}], '
622
+ ... '"children":[], '
623
+ ... '"spouse":null}'
624
+ ... )
625
+ ... )
646
626
  'OK'
647
627
  >>> await glide_json.debug_fields(client, "k1")
648
628
  19
@@ -691,7 +671,22 @@ async def debug_memory(
691
671
  >>> await glide_json.debug_memory(client, "k1", "$[*]")
692
672
  [16, 16, 19, 16, 16, 16, 16, 66, 64]
693
673
 
694
- >>> await glide_json.set(client, "k1", "$", '{"firstName":"John","lastName":"Smith","age":27,"weight":135.25,"isAlive":true,"address":{"street":"21 2nd Street","city":"New York","state":"NY","zipcode":"10021-3100"},"phoneNumbers":[{"type":"home","number":"212 555-1234"},{"type":"office","number":"646 555-4567"}],"children":[],"spouse":null}')
674
+ >>> await glide_json.set(
675
+ ... client,
676
+ ... "k1",
677
+ ... "$",
678
+ ... (
679
+ ... '{"firstName":"John", '
680
+ ... '"lastName":"Smith", '
681
+ ... '"age":27, '
682
+ ... '"weight":135.25, '
683
+ ... '"isAlive":true, '
684
+ ... '"address":{"street":"21 2nd Street","city":"New York","state":"NY","zipcode":"10021-3100"}, '
685
+ ... '"phoneNumbers":[{"type":"home","number":"212 555-1234"},{"type":"office","number":"646 555-4567"}], '
686
+ ... '"children":[], '
687
+ ... '"spouse":null}'
688
+ ... )
689
+ ... )
695
690
  'OK'
696
691
  >>> await glide_json.debug_memory(client, "k1")
697
692
  472
@@ -815,14 +810,16 @@ async def mget(
815
810
  >>> import json
816
811
  >>> json_strs = await glide_json.mget(client, ["doc1", "doc2"], "$")
817
812
  >>> [json.loads(js) for js in json_strs] # Parse JSON strings to Python data
818
- [[{"a": 1.0, "b": 2}], [{"a": 2.0, "b": {"a": 3.0, "b" : 4.0}}]] # JSON objects retrieved from keys `doc1` and `doc2`
813
+ [[{"a": 1.0, "b": 2}], [{"a": 2.0, "b": {"a": 3.0, "b" : 4.0}}]] # JSON objects retrieved from keys
814
+ # `doc1` and `doc2`
819
815
  >>> await glide_json.mget(client, ["doc1", "doc2"], "$.a")
820
816
  [b"[1.0]", b"[2.0]"] # Returns values at path '$.a' for the JSON documents stored at `doc1` and `doc2`.
821
817
  >>> await glide_json.mget(client, ["doc1"], "$.non_existing_path")
822
- [None] # Returns an empty array since the path '$.non_existing_path' does not exist in the JSON document stored at `doc1`.
818
+ [None] # Returns an empty array since the path '$.non_existing_path' does not exist in the JSON document
819
+ # stored at `doc1`.
823
820
  """
824
821
  args = ["JSON.MGET"] + keys + [path]
825
- return cast(TJsonResponse[Optional[bytes]], await client.custom_command(args))
822
+ return cast(List[Optional[bytes]], await client.custom_command(args))
826
823
 
827
824
 
828
825
  async def numincrby(
@@ -843,7 +840,8 @@ async def numincrby(
843
840
  Returns:
844
841
  bytes:
845
842
  For JSONPath (`path` starts with `$`):
846
- Returns a bytes string representation of an array of bulk strings, indicating the new values after incrementing for each matched `path`.
843
+ Returns a bytes string representation of an array of bulk strings, indicating the new values after
844
+ incrementing for each matched `path`.
847
845
  If a value is not a number, its corresponding return value will be `null`.
848
846
  If `path` doesn't exist, a byte string representation of an empty array will be returned.
849
847
  For legacy path (`path` doesn't start with `$`):
@@ -885,7 +883,8 @@ async def nummultby(
885
883
  Returns:
886
884
  bytes:
887
885
  For JSONPath (`path` starts with `$`):
888
- Returns a bytes string representation of an array of bulk strings, indicating the new values after multiplication for each matched `path`.
886
+ Returns a bytes string representation of an array of bulk strings, indicating the new values after
887
+ multiplication for each matched `path`.
889
888
  If a value is not a number, its corresponding return value will be `null`.
890
889
  If `path` doesn't exist, a byte string representation of an empty array will be returned.
891
890
  For legacy path (`path` doesn't start with `$`):
@@ -915,7 +914,8 @@ async def objlen(
915
914
  path: Optional[TEncodable] = None,
916
915
  ) -> Optional[TJsonResponse[int]]:
917
916
  """
918
- Retrieves the number of key-value pairs in the object stored at the specified `path` within the JSON document stored at `key`.
917
+ Retrieves the number of key-value pairs in the object stored at the specified `path` within the JSON document stored at
918
+ `key`.
919
919
 
920
920
  Args:
921
921
  client (TGlideClient): The client to execute the command.
@@ -1025,8 +1025,10 @@ async def resp(
1025
1025
  JSON integers are mapped to RESP Integers.\n
1026
1026
  JSON doubles are mapped to RESP Bulk Strings.\n
1027
1027
  JSON strings are mapped to RESP Bulk Strings.\n
1028
- JSON arrays are represented as RESP arrays, where the first element is the simple string [, followed by the array's elements.\n
1029
- JSON objects are represented as RESP object, where the first element is the simple string {, followed by key-value pairs, each of which is a RESP bulk string.\n
1028
+ JSON arrays are represented as RESP arrays, where the first element is the simple string [, followed by the array's
1029
+ elements.\n
1030
+ JSON objects are represented as RESP object, where the first element is the simple string {, followed by key-value pairs,
1031
+ each of which is a RESP bulk string.\n
1030
1032
 
1031
1033
 
1032
1034
  Args:
@@ -1080,13 +1082,15 @@ async def strappend(
1080
1082
  Args:
1081
1083
  client (TGlideClient): The client to execute the command.
1082
1084
  key (TEncodable): The key of the JSON document.
1083
- value (TEncodable): The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.
1085
+ value (TEncodable): The value to append to the string. Must be wrapped with single quotes. For example,
1086
+ to append "foo", pass '"foo"'.
1084
1087
  path (Optional[TEncodable]): The path within the JSON document. Default to None.
1085
1088
 
1086
1089
  Returns:
1087
1090
  TJsonResponse[int]:
1088
1091
  For JSONPath (`path` starts with `$`):
1089
- Returns a list of integer replies for every possible path, indicating the length of the resulting string after appending `value`,
1092
+ Returns a list of integer replies for every possible path, indicating the length of the resulting string after
1093
+ appending `value`,
1090
1094
  or None for JSON values matching the path that are not string.
1091
1095
  If `key` doesn't exist, an error is raised.
1092
1096
  For legacy path (`path` doesn't start with `$`):
@@ -1102,11 +1106,14 @@ async def strappend(
1102
1106
  >>> await glide_json.set(client, "doc", "$", json.dumps({"a":"foo", "nested": {"a": "hello"}, "nested2": {"a": 31}}))
1103
1107
  'OK'
1104
1108
  >>> await glide_json.strappend(client, "doc", json.dumps("baz"), "$..a")
1105
- [6, 8, None] # The new length of the string values at path '$..a' in the key stored at `doc` after the append operation.
1109
+ [6, 8, None] # The new length of the string values at path '$..a' in the key stored at `doc` after the append
1110
+ # operation.
1106
1111
  >>> await glide_json.strappend(client, "doc", '"foo"', "nested.a")
1107
- 11 # The length of the string value after appending "foo" to the string at path 'nested.array' in the key stored at `doc`.
1112
+ 11 # The length of the string value after appending "foo" to the string at path 'nested.array' in the key stored
1113
+ # at `doc`.
1108
1114
  >>> json.loads(await glide_json.get(client, json.dumps("doc"), "$"))
1109
- [{"a":"foobaz", "nested": {"a": "hellobazfoo"}, "nested2": {"a": 31}}] # The updated JSON value in the key stored at `doc`.
1115
+ [{"a":"foobaz", "nested": {"a": "hellobazfoo"}, "nested2": {"a": 31}}] # The updated JSON value in the key stored
1116
+ # at `doc`.
1110
1117
  """
1111
1118
 
1112
1119
  return cast(
@@ -1152,7 +1159,8 @@ async def strlen(
1152
1159
  >>> await glide_json.strlen(client, "doc", "nested.a")
1153
1160
  5 # The length of the JSON value at path 'nested.a' in the key stored at `doc`.
1154
1161
  >>> await glide_json.strlen(client, "doc", "$")
1155
- [None] # Returns an array with None since the value at root path does in the JSON document stored at `doc` is not a string.
1162
+ [None] # Returns an array with None since the value at root path does in the JSON document stored at `doc` is not
1163
+ # a string.
1156
1164
  >>> await glide_json.strlen(client, "non_existing_key", ".")
1157
1165
  None # `key` doesn't exist.
1158
1166
  """
@@ -1193,14 +1201,21 @@ async def toggle(
1193
1201
  Examples:
1194
1202
  >>> from glide import glide_json
1195
1203
  >>> import json
1196
- >>> await glide_json.set(client, "doc", "$", json.dumps({"bool": True, "nested": {"bool": False, "nested": {"bool": 10}}}))
1204
+ >>> await glide_json.set(
1205
+ ... client,
1206
+ ... "doc",
1207
+ ... "$",
1208
+ ... json.dumps({"bool": True, "nested": {"bool": False, "nested": {"bool": 10}}})
1209
+ ... )
1197
1210
  'OK'
1198
1211
  >>> await glide_json.toggle(client, "doc", "$.bool")
1199
- [False, True, None] # Indicates successful toggling of the Boolean values at path '$.bool' in the key stored at `doc`.
1212
+ [False, True, None] # Indicates successful toggling of the Boolean values at path '$.bool' in the key stored at
1213
+ # `doc`.
1200
1214
  >>> await glide_json.toggle(client, "doc", "bool")
1201
1215
  True # Indicates successful toggling of the Boolean value at path 'bool' in the key stored at `doc`.
1202
1216
  >>> json.loads(await glide_json.get(client, "doc", "$"))
1203
- [{"bool": True, "nested": {"bool": True, "nested": {"bool": 10}}}] # The updated JSON value in the key stored at `doc`.
1217
+ [{"bool": True, "nested": {"bool": True, "nested": {"bool": 10}}}] # The updated JSON value in the key stored at
1218
+ # `doc`.
1204
1219
  """
1205
1220
 
1206
1221
  return cast(