From 44ebfa3bb830bf2472d85a0d112737a9935cf9b9 Mon Sep 17 00:00:00 2001 From: YBoy <231405196+YB0y@users.noreply.github.com> Date: Mon, 13 Apr 2026 02:52:12 +0200 Subject: [PATCH] refactor(api): type _get_cluster_connection_health_params with TypedDict (#34999) --- api/extensions/ext_redis.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/api/extensions/ext_redis.py b/api/extensions/ext_redis.py index a619b9342d..20f05b8b9e 100644 --- a/api/extensions/ext_redis.py +++ b/api/extensions/ext_redis.py @@ -141,6 +141,12 @@ class RedisHealthParamsDict(TypedDict): health_check_interval: int | None +class RedisClusterHealthParamsDict(TypedDict): + retry: Retry + socket_timeout: float | None + socket_connect_timeout: float | None + + class RedisBaseParamsDict(TypedDict): username: str | None password: str | None @@ -211,7 +217,7 @@ def _get_connection_health_params() -> RedisHealthParamsDict: ) -def _get_cluster_connection_health_params() -> dict[str, Any]: +def _get_cluster_connection_health_params() -> RedisClusterHealthParamsDict: """Get retry and timeout parameters for Redis Cluster clients. RedisCluster does not support ``health_check_interval`` as a constructor @@ -219,8 +225,13 @@ def _get_cluster_connection_health_params() -> dict[str, Any]: here. Only ``retry``, ``socket_timeout``, and ``socket_connect_timeout`` are passed through. """ - params: dict[str, Any] = dict(_get_connection_health_params()) - return {k: v for k, v in params.items() if k != "health_check_interval"} + health_params = _get_connection_health_params() + result: RedisClusterHealthParamsDict = { + "retry": health_params["retry"], + "socket_timeout": health_params["socket_timeout"], + "socket_connect_timeout": health_params["socket_connect_timeout"], + } + return result def _get_base_redis_params() -> RedisBaseParamsDict: