redis 6.4.0__py3-none-any.whl → 7.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.
Files changed (59) hide show
  1. redis/__init__.py +1 -1
  2. redis/_parsers/base.py +193 -8
  3. redis/_parsers/helpers.py +64 -6
  4. redis/_parsers/hiredis.py +16 -10
  5. redis/_parsers/resp3.py +11 -5
  6. redis/asyncio/client.py +65 -8
  7. redis/asyncio/cluster.py +57 -5
  8. redis/asyncio/connection.py +62 -2
  9. redis/asyncio/http/__init__.py +0 -0
  10. redis/asyncio/http/http_client.py +265 -0
  11. redis/asyncio/multidb/__init__.py +0 -0
  12. redis/asyncio/multidb/client.py +530 -0
  13. redis/asyncio/multidb/command_executor.py +339 -0
  14. redis/asyncio/multidb/config.py +210 -0
  15. redis/asyncio/multidb/database.py +69 -0
  16. redis/asyncio/multidb/event.py +84 -0
  17. redis/asyncio/multidb/failover.py +125 -0
  18. redis/asyncio/multidb/failure_detector.py +38 -0
  19. redis/asyncio/multidb/healthcheck.py +285 -0
  20. redis/background.py +204 -0
  21. redis/cache.py +1 -0
  22. redis/client.py +97 -16
  23. redis/cluster.py +14 -3
  24. redis/commands/core.py +348 -313
  25. redis/commands/helpers.py +0 -20
  26. redis/commands/json/commands.py +2 -2
  27. redis/commands/search/__init__.py +2 -2
  28. redis/commands/search/aggregation.py +24 -26
  29. redis/commands/search/commands.py +10 -10
  30. redis/commands/search/field.py +2 -2
  31. redis/commands/search/query.py +23 -23
  32. redis/commands/vectorset/__init__.py +1 -1
  33. redis/commands/vectorset/commands.py +43 -25
  34. redis/commands/vectorset/utils.py +40 -4
  35. redis/connection.py +1257 -83
  36. redis/data_structure.py +81 -0
  37. redis/event.py +84 -10
  38. redis/exceptions.py +8 -0
  39. redis/http/__init__.py +0 -0
  40. redis/http/http_client.py +425 -0
  41. redis/maint_notifications.py +810 -0
  42. redis/multidb/__init__.py +0 -0
  43. redis/multidb/circuit.py +144 -0
  44. redis/multidb/client.py +526 -0
  45. redis/multidb/command_executor.py +350 -0
  46. redis/multidb/config.py +207 -0
  47. redis/multidb/database.py +130 -0
  48. redis/multidb/event.py +89 -0
  49. redis/multidb/exception.py +17 -0
  50. redis/multidb/failover.py +125 -0
  51. redis/multidb/failure_detector.py +104 -0
  52. redis/multidb/healthcheck.py +282 -0
  53. redis/retry.py +14 -1
  54. redis/utils.py +34 -0
  55. {redis-6.4.0.dist-info → redis-7.0.0.dist-info}/METADATA +7 -4
  56. redis-7.0.0.dist-info/RECORD +105 -0
  57. redis-6.4.0.dist-info/RECORD +0 -78
  58. {redis-6.4.0.dist-info → redis-7.0.0.dist-info}/WHEEL +0 -0
  59. {redis-6.4.0.dist-info → redis-7.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,3 +1,5 @@
1
+ import json
2
+
1
3
  from redis._parsers.helpers import pairs_to_dict
2
4
  from redis.commands.vectorset.commands import CallbacksOptions
3
5
 
@@ -75,19 +77,53 @@ def parse_vsim_result(response, **options):
75
77
  structures depending on input options.
76
78
  Parsing VSIM result into:
77
79
  - List[List[str]]
78
- - List[Dict[str, Number]]
80
+ - List[Dict[str, Number]] - when with_scores is used (without attributes)
81
+ - List[Dict[str, Mapping[str, Any]]] - when with_attribs is used (without scores)
82
+ - List[Dict[str, Union[Number, Mapping[str, Any]]]] - when with_scores and with_attribs are used
83
+
79
84
  """
80
85
  if response is None:
81
86
  return response
82
87
 
83
- if options.get(CallbacksOptions.WITHSCORES.value):
88
+ withscores = bool(options.get(CallbacksOptions.WITHSCORES.value))
89
+ withattribs = bool(options.get(CallbacksOptions.WITHATTRIBS.value))
90
+
91
+ # Exactly one of withscores or withattribs is True
92
+ if (withscores and not withattribs) or (not withscores and withattribs):
84
93
  # Redis will return a list of list of pairs.
85
94
  # This list have to be transformed to dict
86
95
  result_dict = {}
87
- for key, value in pairs_to_dict(response).items():
88
- value = float(value)
96
+ if options.get(CallbacksOptions.RESP3.value):
97
+ resp_dict = response
98
+ else:
99
+ resp_dict = pairs_to_dict(response)
100
+ for key, value in resp_dict.items():
101
+ if withscores:
102
+ value = float(value)
103
+ else:
104
+ value = json.loads(value) if value else None
105
+
89
106
  result_dict[key] = value
90
107
  return result_dict
108
+ elif withscores and withattribs:
109
+ it = iter(response)
110
+ result_dict = {}
111
+ if options.get(CallbacksOptions.RESP3.value):
112
+ for elem, data in response.items():
113
+ if data[1] is not None:
114
+ attribs_dict = json.loads(data[1])
115
+ else:
116
+ attribs_dict = None
117
+ result_dict[elem] = {"score": data[0], "attributes": attribs_dict}
118
+ else:
119
+ for elem, score, attribs in zip(it, it, it):
120
+ if attribs is not None:
121
+ attribs_dict = json.loads(attribs)
122
+ else:
123
+ attribs_dict = None
124
+
125
+ result_dict[elem] = {"score": float(score), "attributes": attribs_dict}
126
+ return result_dict
91
127
  else:
92
128
  # return the list of elements for each level
93
129
  # list of lists